我在这里发现的那个动画有问题: jQuery animated number counter from zero to value
这就是问题所在,我在测试网站上使用它,当它有大数字时,计数器不会显示准确的值。
这是 HTML:
<span class="Count">66620</span>
<br/>
<span class="Count">66666666</span>
<br/>
<span class="Count">66666666</span>
这是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));
}
});
});
有人有想法吗?
提前致谢。
最佳答案
为什么不直接使用回调的第一个参数呢?
step
Type: Function( Number now, Tween tween )
step: function (i) {
$this.text(Math.ceil(i));
}
关于javascript - jquery动画编号从到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24904980/