我需要这个计数器从滚动开始,而不是之前。是否可以?function startCounter(){ $('.counter').each(function (index) { $(this).prop('Counter',0).animate({ Counter: $(this).text() }, { duration: 2000, easing: 'swing', step: function (now) { $(this).text(Math.round(now*10)/10); } }); });} startCounter();<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><span class="counter">92.2</span>
2 回答

牧羊人nacy
TA贡献1862条经验 获得超7个赞
这将为您做到。
window.addEventListener('scroll', function(e) {
startCounter();
});
添加回答
举报
0/150
提交
取消