Count from a number to a target number script and use it in multiple boxes
I found that on another topic:
$({countNum: $('.skill-counter').text()}).animate({countNum: 90}, {
duration: 2000,
easing:'linear',
step: function() {
$('.skill-counter').text(Math.floor(this.countNum)+1 +('%'));
}
});
What I am trying to change with this is to put this in a function and use
it in multiple boxes with different count values.
What I have done so far:
var count = function(counTo, divName){
this.counTo = 0;
$(counTo).animate({counTo: counTo},{
duration: 2000,
easing:'linear',
step: function() {
$(divName).text(Math.floor(counTo)+1 +('%'));
}
});
};
count(90,'box1');
count(70,'box2');
count(50,'box3');
It doesn't work and probably that's normal because it's totally wrong! So
How can I do that?
No comments:
Post a Comment