Created
August 29, 2014 07:56
-
-
Save fanian/0de48b040fec59fa2b80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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