function formatter(b, a) {
    return b.toFixed()
}
$("#count-number").data("countToOptions", {
    formatter: function(b, a) {
        return b.toFixed().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",")
    }
});
//toFixed()  控制小数点后显示几位
                                    
                                            搞定了,弄个div,然后apeend  html就可以。
<script>
 function getdatahtml()
 {
     var i=Math.random()*100;
    // alert(i);
     var operation_html="<h2 class='timer count-title'  data-from='100' data-to='"+i+"' data-speed='1500'></h2>";
      return operation_html;
 }
</script>
<body>
   <button onclick=" $('#p1').html('');$('#p1').append(getdatahtml());$('.timer').each(count); " >test</button>
   <div id="p1"><h2 class='timer count-title'  data-from='0' data-to='0' data-speed='100'></h2></div>
</body>
                                                    
                                                作者你好,发现了很奇怪的问题,为什么传进去的数字输出来会减少一个呢,比如data-to="11"输出的是10,而且不规则
你好,我使用了ajax向后台拿到数据,在放在ajax的回调函数success: function(data) {}里面,data-form和data-to都附上值了,但是数字没累加起来,显示0
回复非常感谢楼主,我想在数字前面加个+号或者字母什么的该怎么修改呢?求教
我是拿后台的数据ajax动态获取
$("#monthMoney").attr("data-to",result.month);数值没有变是显示0.00