jQuery count up individual
by jack_pallot
HTML
<h2 class="clients"></h2>
<h2 class="services"></h2>
<h2 class="years"></h2>
JavaScript
! function (a) {
a.fn.countTo = function (b) {
b = a.extend({}, a.fn.countTo.defaults, b || {});
var c = Math.ceil(b.speed / b.refreshInterval),
d = (b.to - b.from) / c;
return a(this).each(function () {
function i() {
setTimeout(function(){
g += d, f++, a(e).html(g.toFixed(b.decimals)), "function" == typeof b.onUpdate && b.onUpdate.call(e, g), f >= c && (clearInterval(h), g = b.to, "function" == typeof b.onComplete && b.onComplete.call(e, g))},b.delay);
}
var e = this,
f = 0,
g = b.from,
h = setInterval(i, b.refreshInterval)
})
}, a.fn.countTo.defaults = {
from: 0,
to: 10,
delay: 3000,
speed: 1e3,
refreshInterval: 10,
decimals: 0,
onUpdate: null,
onComplete: null
}
}(jQuery);
jQuery(function($) {
$('.clients').countTo({
from: 0,
to: 100,
speed: 100,
delay:1000
});
$('.services').countTo({
from: 0,
to: 5,
speed: 1500,
delay:2000
});
$('.years').countTo({
from: 0,
to: 5,
speed: 1500,
delay:2000
});
});