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>