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

145
Views
¿Cómo aparecer el mismo DIV al hacer clic en un botón diferente?

Básicamente, quiero que el usuario sepa visualmente que los datos cambiaron cuando hizo clic en un botón.

Cada vez que el usuario hace clic en un botón diferente, el mismo div tiene que desaparecer y aparecer de nuevo.

Intenté alternar y hacer la transición, pero no funciona, ¡puedes ver que funciona solo cuando haces clic por primera vez!

¡Gracias!

 function showMe(n){ let myDiv = document.getElementById('myDiv'); myDiv.innerHTML = n==1?"Hello Data":"Another Data"; myDiv.style.opacity = '1'; }
 #myDiv { width: 300px; height: 300px; border: 2px solid black; opacity: 0; transition: opacity 1s; }
 <div id="myDiv"></div> <button onclick="showMe(1)">ShowData</button> <button onclick="showMe(100)">AnotherData</button>

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

0

 function showMe(n){ let myDiv = document.getElementById('myDiv'); myDiv.style.opacity = '0'; setTimeout(function(){ myDiv.innerHTML = n==1?"Hello Data":"Another Data"; myDiv.style.opacity = '1'; }, 1000); }
 #myDiv { width: 200px; height: 200px; border: 2px solid black; opacity: 0; transition: opacity 1s; }
 <div id="myDiv"></div> <button onclick="showMe(1)">ShowData</button> <button onclick="showMe(100)">AnotherData</button>

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!