I'm using the latest
timers jQuery plugin and the laetst jQuery available as well.
Here's my code:
- $('#test').everyTime(1000,function(i) {
- if (i>4) {
- i = i-5;
- }
- $('#test').html(i);
- });
And here's the HTML
- <div id="test"></div>
Here's the deal:
When the function starts, "i" starts with a value of "1" and starts increasing +1 every second. So far, so good.
When "i" goes to 5, the script rests 5 from it to make it 0 again. Once again, so far, so good. "i" continues increasing by 1 each second as it's expected.
Problem is, next time "i" reaches 5 it no longer goes back to 0, but continues increasing.
I need to keep "i" from going any bigger than this, so basically, I want "i" to go from 0 to 4 in an infinite loop that increases every second. Can't seem to make it, though.
Any ideas what I'm doing wrong?