via DailyCoding.com

Demo

Code

var index = 0;
var obj = new Timer();
obj.Interval = 30;
obj.Tick = timer_tick;
obj.Start();

function timer_tick()
{
	index  = index + 1;
	document.getElementById("div1").innerHTML =index;
	
	if (index == 100) 
	{
		obj.Stop();
	}
}