ponjoh ponjoh - 11 months ago 35
Javascript Question

Increase the value of a number in an element every x milliseconds

So I have this simple HTML:

<span id="badge">0</span>

I want the number 0 to increase by 1 every x milliseconds. How do I do that with Javascript (with or without jQuery)?

Thanks a bunch - I'm new to this :)


You should do this:

   setInterval(function () {
     var value = parseInt($('#badge').html());
}, 1000);


Assuming 1000 milliseconds.