JS Loop каждые x секунд
(function loop() {
setTimeout(function () {
// execute script
loop()
}, 9000); //9000 = 9000ms = 9s
}());
Sticky Pingu
(function loop() {
setTimeout(function () {
// execute script
loop()
}, 9000); //9000 = 9000ms = 9s
}());
for(var i = 0; i < 3; i++) {
(function(index) {
setTimeout(function() { alert(index); }, index*5000);
})(i);
}
var time = 1;
var interval = setInterval(function() {
if (time <= 3) {
alert(time);
time++;
}
else {
clearInterval(interval);
}
}, 5000);