Question

I am new to jQuery and I was wondering if someone could point me in the right direction regarding the following:

I have a number (0.085) and I am trying to figure out how, starting at 0 I can continuously add 0.085 to itself every second ie:

0, 0.085, 0.17, 0.255, 0.34 - etc.

I eventually would like to animate this so that the numbers look like the second/milliseconds of a stopwatch and actually count to the number. So if anyone knows how best to go about this then that would also be great.

Était-ce utile?

La solution

You need to use setInterval():

var count = 0;
setInterval(function() {
    count += 0.085;
    // update the UI as needed here...
}, 1000); // 1000ms = 1 second
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top