When the number reaches 1000 it adds the comma and becomes like so 1,000 although once it implements the ',' it then resets back to 12 where it should carry on.
Here is my jsFiddle: http://jsfiddle.net/m9cey/3/
var millisecs = 1000;
setInterval(function() {
var $badge = $('#badge');
var num = parseInt($badge.text())+11;
$badge.text(num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
}, millisecs);
Any help will be much appreciated.
Cheers
+ 11? What is that supposed to achieve?parseIntwill parse up to -- BUT NOT INCLUDING -- the comma. The documentation forparseIntwill help you a lot.