I've got a JS script that should change a html element - visibly count 1 to 100. When I add a timeout, the for loop doesn't loop anymore - jumps right to 100. It works with alert but not with the div change.
var theLabel = document.getElementById("counter");
function doSetTimeout(i) {
setTimeout(function() {
/*alert(i); */
theLabel.innerHTML = i;
}, 1000);
}
for (var i = 1; i <= 100; i++)
doSetTimeout(i);