188
rated 0 times
[
194]
[
6]
/ answers: 1 / hits: 30108
/ 14 Years ago, tue, june 15, 2010, 12:00:00
What is the simplest way to increase a variable by 1 every second?
More From » jquery
What is the simplest way to increase a variable by 1 every second?
var counter = 0;
setInterval(function () {
++counter;
}, 1000);
Additionally, if you ever need to turn it off again, this makes that possible:
var counter = 0;
var myInterval = setInterval(function () {
++counter;
}, 1000);
// to stop the counter
clearInterval(myInterval);