Here is my Code:
var sec = 10;
var timer = setInterval(function() {
$('#timer span').text(sec--);
}, 1000);
It sets a setTimeout for 10 seconds. I want to have a reset button that, clicked, calls setTimeout again with a 10 seconds delay.
You would do this by storing the result of your
setTimeout()call to some variable, and then passing the result that you stored toclearTimeout()when the button is clicked, before scheduling a new timeout and assigning it back to the same variable.Sounds a bit tricky but it’s really very simple. Here is an example:
http://jsfiddle.net/kzDdq/