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

100
Views
¿Cómo agregar animación?

¿Cómo agregaré una animación de desvanecimiento en este código javascript?

 document.getElementById("mt-alerts").style.display="block"; setTimeout(function(){ document.getElementById("mt-alerts").style.display="none"; }, 2000);
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Debe crear clases para cada animación, y el JS debe cambiar solo las clases de los elementos. Puedes con este método, hacer tus propias animaciones.

 const alertMsg = document.getElementById("mt-alerts"); const hide = document.getElementById("hide"); const red = document.getElementById("red"); hide.addEventListener("click", ()=> alertMsg.classList.toggle("hidden")); red.addEventListener("click", ()=> alertMsg.classList.toggle("red"));
 #mt-alerts { opacity: 1; transition: all 0.5s linear; color: black; } .hidden { opacity: 0!important; } .red { color: red!important; }
 <div id="mt-alerts">My Alert</div> <button id="hide">Hide/show</button> <button id="red">Make it red</button>

about 4 years ago · Juan Pablo Isaza Report

0

En lugar de usar la pantalla, debe comenzar con la opacidad para esto.

La idea es simplemente disminuir la opacidad de su elemento hasta que llegue a 0, luego configure su visualización como ninguno. Para desvanecerse, puede repetir la idea al revés.

 function js_fadeOut(targetID, intervalMs, fadeWeight) { var fadeTarget = document.getElementById(targetID); var fadeEffect = setInterval(function () { if (!fadeTarget.style.opacity) { fadeTarget.style.opacity = 1; } if (fadeTarget.style.opacity > 0) { fadeTarget.style.opacity -= fadeWeight; } else { fadeTarget.style.display = "none"; clearInterval(fadeEffect); } }, intervalMs*fadeWeight); }
 <div id='target' style='padding:8px; background:lightblue;' onclick='js_fadeOut("target", 200, 0.1)'>Click to fadeOut</div>

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!