var iii = 0; //t is unqiue representer of this timer. //the callback is executed every 1000ms var t = setInterval(function(){ var element = document.getElementById("box"); element.innerHTML = iii++; if(iii == 100) { clearInterval(t);//stops the timer } }, 1000);//1000ms is the execution delay
<div id="box"></div>