<html>
<body>
<span>look this:</span><span id="nums">10000</span>
</body>
</heml>
<script type="text/javascript">
var totalNum = 10000;
var nums = 0;
// 調用計時函數
setTimeout(timedCount(nums),50);
// 循環計時函數, 多次調用自身函數, nums為被傳遞的參數
function timedCount(nums){
var count = Math.round(totalNum/97);
nums = nums+count;
document.getElementById('nums').innerHTML =nums
// $("#nums").text(nums);
// 設置條件使停止計時
if (nums<totalNum) {
setTimeout(function(){timedCount(nums)},50);
}else{
document.getElementById('nums').innerHTML =totalNum
}
}
</script>
