Skip to content

Instantly share code, notes, and snippets.

@meeDamian
Created November 21, 2011 12:29
Show Gist options
  • Save meeDamian/1382510 to your computer and use it in GitHub Desktop.
Save meeDamian/1382510 to your computer and use it in GitHub Desktop.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script type="text/javascript">
function animateCount($node) {
// nodes, values
var $val= $node.find('.number');
var val = parseInt($val.text());
$val.html('0');
// time variables
var current = 0;
var miliceconds = 2000;
var counter = setInterval(function(){
if(current >= val) clearInterval(counter);
$val.text(current);
current = parseInt(current) + 1;
}, miliseconds / val);
}
$( animateCount($('#listElement')) );
</script>
<li id="listElement">
<span class="number">22</span>
<strong>Dziwek</strong>
</li>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment