문제

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.

도움이 되었습니까?

해결책

You need to use setInterval():

var count = 0;
setInterval(function() {
    count += 0.085;
    // update the UI as needed here...
}, 1000); // 1000ms = 1 second
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top