js repeat loop every 5 seconds code example
Example 1: js loop every x seconds
(function loop() {
setTimeout(function () {
// execute script
loop()
}, 9000); //9000 = 9000ms = 9s
}());
Example 2: loop every 5 seconds
for(var i = 0; i < 3; i++) {
(function(index) {
setTimeout(function() { alert(index); }, index*5000);
})(i);
}