Skip to content

Instantly share code, notes, and snippets.

@dpmango
Created January 24, 2017 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpmango/a80925326d8431a30c3a78cddd590dc6 to your computer and use it in GitHub Desktop.
Save dpmango/a80925326d8431a30c3a78cddd590dc6 to your computer and use it in GitHub Desktop.
$.fn.digits = function(){
return this.each(function(){
$(this).text( $(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") );
})
}
$('#animateItem').each(function () {
$(this).prop('Counter',0).animate({
Counter: $(this).text()
}, {
duration: 2000,
easing: 'swing',
step: function (now) {
$(this).text(Math.ceil(now)).digits();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment