我在这里找到的动画有一个问题: jQuery动画数字计数器从零到值
这是问题所在,我在测试网站上使用它,并且计数器在大数字时没有确切的值.
这是HTML:
<span class="Count">66620</span>
<br/>
<span class="Count">66666666</span>
<br/>
<span class="Count">66666666</span>
Run Code Online (Sandbox Code Playgroud)
这是javascript:
$('.Count').each(function () {
var $this = $(this);
jQuery({ Counter: 0 }).animate({ Counter: $this.text() }, {
duration: 1000,
easing: 'swing',
step: function () {
$this.text(Math.ceil(this.Counter));
}
});
});
Run Code Online (Sandbox Code Playgroud)
有人有想法吗?
提前致谢.
为什么不简单地使用回调的第一个参数?
步
类型:函数(现在的数字,补间补间)
step: function (i) {
$this.text(Math.ceil(i));
}
Run Code Online (Sandbox Code Playgroud)