How can i make this counter in infinite loop with timeout function. Here is my code. any help highly appreciated.
HTML
<div class="counter inner">
<ul>
<li>
<h5 class="count">35</h5>
<p>Years</p>
</li>
<li>
<h5 class="count">150</h5>
<p>Employees</p>
</li>
</ul>
</div>
JS
$('.count').each(function () {
$(this).prop('Counter',0).animate({
Counter: $(this).text()
}, {
duration: 2000,
easing: 'swing',
step: function (now) {
$(this).text(Math.ceil(now));
}
});
});
Use a complete callback, reset the counter, and call the animation again.
$('.count').each(function anim() {
$(this).prop('Counter',0).animate({
Counter: $(this).text()
}, {
duration: 2000,
easing: 'swing',
step: function (now) {
$(this).text(Math.ceil(now));
},
complete: function(){
$(this).css('counter',0);
setTimeout(anim.bind(this),1000);
}
});
});
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다