How to add controls to a javascipt timer

by Ranganathan 2012-08-29 00:06:57

How to add a 'pause', 'resume', 'reset' and 'end' functions to the following javascript count-up timer?

var sec = 0;

function pad(val) {
return val > 9 ? val : "0" + val;
}
setInterval(function() {
document.getElementById("seconds").innerHTML = pad(++sec % 60);
document.getElementById("minutes").innerHTML = pad(parseInt(sec / 60, 10));
}, 1000);

859
like
0
dislike
0
mail
flag

You must LOGIN to add comments