Skip to content

Instantly share code, notes, and snippets.

@Radagaisus
Created September 5, 2011 11:36
Show Gist options
  • Save Radagaisus/1194760 to your computer and use it in GitHub Desktop.
Save Radagaisus/1194760 to your computer and use it in GitHub Desktop.
Animate Numbers jQuery Plugin
// usage: $(".something").animateNums(300);
(function($) {
$.fn.animateNums = function(options) {
return this.each(function() {
e = $(this);
var max = e.text();
e.text("0");
animateNums();
function animateNums() {
if (e.text() < max) {
e.text(Number(e.text()) + 1);
setInterval(animateNums, options.speed);
}
}
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment