Answer the question
In order to leave comments, you need to log in
How to reset recursive js counter?
Hello!
There is a recursive counter (timer) in seconds.
<span class="start">Start</span>
<input type="text" id="timer" name="timer" value=1>
$('span.start').click(function(){
var timer=1;
var interval = 1000;
var refresh = function() {
$('#timer').val(timer);
timerId = setTimeout(function() {
timer++;
refresh();
}, interval);
};
refresh();
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question