jQuery 向上计数

2024-03-20

我不太擅长 javascript,但我希望有一个漂亮的小动画,可以向上计数数字。我发现了this http://sophilabs.github.io/jquery-counter/在 Github 上,但是速度很慢。 (我正在计算一个小数点后10位的数字)。有人知道如何修改它,以便更快地进行修改吗? (我试图减少数据间隔,但它有点停滞在“0”。

<p class="counter" data-interval="0" data-format="999999" data-stop="193847"></p>

这会对你有帮助,也很简单,你可以通过改变持续时间来改变速度 and 改变起始号码通过改变计数器:0

$('.count').each(function () {
  var $this = $(this);
  jQuery({ Counter: 0 }).animate({ Counter: $this.attr('data-stop') }, {
    duration: 1000,
    easing: 'swing',
    step: function (now) {
      $this.text(Math.ceil(now));
    }
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span class="count" data-stop="193847">193847</span>
<br/>
<span class="count" data-stop="190">190</span>
<br/>
<span class="count" data-stop="1938">1938</span>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

jQuery 向上计数 的相关文章