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();
remove
var i = 1;beforevar j = (i - 1);and add it here