Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

256
Vistas
How can I decrease the opacity of an element by 0.1 every 100 milliseconds?

I am trying to make it so every 100 milliseconds, the opacity of a specified element decreases by 0.1. Here's my code:

       var loader = this.document.getElementById("loader");
       var op;
       for(op = 1.0; op > 0.0; op -= 0.1){
          window.setTimeout(function(){
              c.style.opacity = op.toString();
              loader.style.opacity = op.toString();
          }, 100)
       }

Am I potentially creating an infinite loop that I'm not aware of?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

An easy way to do this would be with the setInterval("yourFunctionHere()", 100) This will make the function you add run in the background and execute every 100 milliseconds. Just put your set opacity stuff into a function and execute it in the setInterval

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda