Skip to content

Instantly share code, notes, and snippets.

@fanian
Created August 29, 2014 07:56
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 fanian/0de48b040fec59fa2b80 to your computer and use it in GitHub Desktop.
Save fanian/0de48b040fec59fa2b80 to your computer and use it in GitHub Desktop.
function counter() {
var stepCount = 20;
var time = 2000;
var stepTime = time / stepCount;
var count1 = $('#count_1').text();
var count2 = $('#count_2').text();
var count3 = $('#count_3').text();
var count4 = $('#count_4').text();
var count5 = $('#count_5').text();
var i = 0;
var int = setInterval(function() {
$('#count_1').text(parseInt((count1 / stepCount) * i));
$('#count_2').text(parseInt((count2 / stepCount) * i));
$('#count_3').text(parseInt((count3 / stepCount) * i));
$('#count_4').text(parseInt((count4 / stepCount) * i));
$('#count_5').text(parseInt((count5 / stepCount) * i));
i++;
if (i > stepCount) {
clearInterval(int);
}
}, stepTime);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment