Answers for "run for loop every second js"

0

js loop every x seconds

(function loop() {
  setTimeout(function () {
    // execute script
    loop()
  }, 9000); //9000 = 9000ms = 9s
}());
Posted by: Guest on November-09-2020
0

loop every 5 seconds

for(var i = 0; i < 3; i++) {
    (function(index) {
        setTimeout(function() { alert(index); }, index*5000);
    })(i);
}
Posted by: Guest on May-07-2020
0

run for loop every second js

var time = 1;

var interval = setInterval(function() { 
   if (time <= 3) { 
      alert(time);
      time++;
   }
   else { 
      clearInterval(interval);
   }
}, 5000);
Posted by: Guest on January-09-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language