I have a for loop with a setTimeout function inside of it intended to delay each iteration of the loop. While the rest of the code within the loop is properly iterating, the setTimeout function only works once, as if the for loop was inside of it and not the other way around. Here's my code:
for (x = 0; x <= roll; x ++) {
setTimeout(function() {
space = $(".player." + turn).parents("td").attr("id");
space = parseInt(space);
player = $(".player." + turn);
$(".player." + turn).remove();
nextSpace = space + 1;
$("#" + nextSpace).append(player);
}, 500);
}
Any ideas?