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

250
Views
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 answers
Answer question

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 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!