Install:
Download the jQuery timer plugin and put it in a SCRIPT tag in your HTML page after jQuery itself.
Start a timer:
$('#divId').timer(); //Same as $('#divId').timer('start')
Start at a particular time:
$('#divId').timer({
seconds: 100 //Specify start time in seconds
});
Pause:
$('#divId').timer('pause');
Resume:
$('#divId').timer('resume');
Remove Timer:
$('#divId').timer('remove');
Get number of seconds:
$('#divId').data('seconds');
Get notified:
//start a timer & execute a function in 5 minutes & 30 seconds
$('#divId').timer({
duration: '5m30s',
callback: function() {
alert('Time up!');
}
});
Get notified:
//start a timer & execute a function every 2 minutes
$('#divId').timer({
duration: '2m',
callback: function() {
alert('Why, Hello there');
},
repeat: true //repeatedly calls the callback you specify
});
Repeat callback & reset timer:
//start a timer & execute a function every 30 seconds and then reset the timer at the end of 30 seconds.
$('#divId').timer({
duration: '30s',
callback: function() {
console.log('Timer will reset!');
},
repeat: true, //repeatedly call the callback
reset: true //optionally reset the timer to 0
});