Count up numbers in JavaScript

$(function() { function count($this){ var current = parseInt($this.html(), 10); $this.html(++current); if(current !== $this.data('count')){ setTimeout(function(){count($this)}, 50); } } $("span").each(function() { $(this).data('count', parseInt($(this).html(), 10)); $(this).html('0'); count($(this)); }); });

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.