<script>
var START_DATE = new Date("January 01, 2013 00:00:00");
var INTERVAL = 0.25;
var INCREMENT = 0.001;
var START_VALUE = 0;
var count = 0;
function addCommas(str){
var arr,int,dec;
str += '';
arr = str.split('.');
int = arr[0] + '';
dec = arr.length>1?'.'+arr[1]:'';
return int.replace(/(\d)(?=(\d{3})+$)/g,"$1,") + dec;
}window.onload = function(){
var msInterval = INTERVAL * 1000;
var now = new Date();
count = parseInt((now - START_DATE)/msInterval) * INCREMENT + START_VALUE;
document.getElementById('counter').innerHTML = addCommas(count);
setInterval("count += INCREMENT; document.getElementById('counter').innerHTML = addCommas(count);", msInterval);
}
</script>
<div id="counter"> 30k</div>
我必须将 .toFixed(2) 放在哪里,以便我们的非营利组织的餐食柜台只显示小数点后两位。我尝试了许多不同的地方,但不确定 .toFixed 是否是正确的解决方案。请协助