JQuery-Timer is a project mainly written in JavaScript, it's free.
Timer class for jQuery
function init(){
var timer = new Timer(1000,10); //instantiate a timer to tick 10 times each 1000 milliseconds
timer.bind(Timer.TICK,function(event,info){
// info has the current_count and last properties.
console.log("*",timer.is_running(),info.current_count,info.last)
})
timer.start(); //start timer
var _timer = new Timer(500); //instantiate a timer to tick each 500 milliseconds indefinitely
_timer.start();
_timer.tick(function(event,info){
console.log("=",_timer.is_running(),info.current_count)
})
setInterval(function(){
if(_timer.current_count() == 3) _timer.stop(); // stop timer when the tick count reaches 3
if(timer.current_count() == 10) timer.stop(true); // stop timer when the tick count reaches 10, will run a last iteration before stopping
},200)
}
$(document).ready(init);