I have seen this sort of information floating around but I cannot figure out why my particular setup is flashing through the function so fast.
Here is what I am trying to do:
I have squares on a page that I need to glow in order, but 500 milliseconds apart. I store the jQuery identifier in an array and cycle through it.
function glow(source) {// glows
$(source).addClass("square-active")
setTimeout(function() {
$(source).removeClass("square-active");
}, 500);
}
function iterator() {
var y = 0;
setTimeout(function() {
for (var t=0; t<newComp.slice(0, numTurn).length; t++) {
glow(squareArr[newComp[t]].div)
y = y + 1
}
}, 500 * y)
}
I know that the squares are being iterated through properly because I have that logged to the console for verification purposes. I can see the squares flash in order, but it is insanely fast.
When I attempt to wrap the glow() function in setInterval I do not believe it works either.
What am I doing wrong?