Skip to content

Instantly share code, notes, and snippets.

@abovedave
Created August 4, 2014 16:50
Show Gist options
  • Save abovedave/62e96e03512775fd0458 to your computer and use it in GitHub Desktop.
Save abovedave/62e96e03512775fd0458 to your computer and use it in GitHub Desktop.
Count up from a given number (jquery(
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
$('.count ul li strong').each(function(){
var start = parseInt($(this).text(), 10);
var _self = $(this);
setInterval(function(){
var update = start++;
_self.text(numberWithCommas(update));
}, Math.floor(Math.random() * 450) + 80);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment