this is my first post on the forum. Here i have a javascript attempting to loop, and to set each element as an active class, then wait, remove the class and add it to the next element. My problem is that it does the first one, then no more...
var i = 1;
function myLoop() {
setTimeout(function() {
var i = 1;
var j = (i - 1);
$("#nH" + j).removeClass("active");
$("#nH" + i).addClass("active");
i++;
if (i < 5) {
myLoop();
}
}, 3000)
}
myLoop();
myLoopindefinitely... and it's not really a loop, it's recursion. The whole approach is a bit confusing.