Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

419
Views
¿Cómo cambiar la opacidad de un div al hacer clic en el botón usando JS?

Estoy tratando de agregar un script a mi archivo HTML que cambia la opacidad de un div cuando se hace clic en un botón.

Este es el archivo HTML

Este es el archivo CSS

esta es mi funcion

Esencialmente, lo que estoy tratando de lograr es que el div que actualmente está configurado en 0 opacidad, cambiará a 1 opacidad al hacer clic en el botón. Actualmente esto no funciona, y soy relativamente nuevo en la incorporación de JS en un archivo HTML. Algún consejo sería de gran aprecio.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Aquí hay un ejemplo simple usando JavaScript incrustado en HTML. Asegúrese de estar utilizando un detector de eventos que escuche el clic de su botón.

 <!DOCTYPE html> <html> <head> <title>About Me</title> </head> <body> <h1 style="opacity: 0;">About Me</h1> <button> Show </button> <script> var button = document.querySelector('button'); button.addEventListener('click', function() { var h1 = document.querySelector('h1'); h1.style.opacity = 1; }); </script> </body> </html>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!