小编kev*_*lar的帖子

如何使用jQuery使用逗号使用动画来增加数字?

我正在尝试在页面上的元素内增加一个数字.但是我需要用数字来包含第千个值的逗号.(例如45,000而不是45000)

<script>
// Animate the element's value from x to y:
  $({someValue: 40000}).animate({someValue: 45000}, {
      duration: 3000,
      easing:'swing', // can be anything
      step: function() { // called on every step
          // Update the element's text with rounded-up value:
          $('#el').text(Math.round(this.someValue));
      }
  });
</script>
<div id="el"></div>
Run Code Online (Sandbox Code Playgroud)

如何使用动画使用逗号增加数字?

jquery increment comma easing jquery-animate

9
推荐指数
2
解决办法
2万
查看次数

标签 统计

comma ×1

easing ×1

increment ×1

jquery ×1

jquery-animate ×1