2 回答
TA贡献1858条经验 获得超8个赞
<html>
<head>
<meta charset="utf-8">
<script>
var timeCounter = (function() {
var int;
var total = 3600;
return function(elemID) {
obj = document.getElementById(elemID);
var s = (total%60) < 10 ? ('0' + total%60) : total%60;
var h = total/3600 < 10 ? ('0' + parseInt(total/3600)) : parseInt(total/3600);
var m = (total-h*3600)/60 < 10 ? ('0' + parseInt((total-h*3600)/60)) : parseInt((total-h*3600)/60);
obj.innerHTML = h + ' : ' + m + ' : ' + s;
total--;
int = setTimeout("timeCounter('" + elemID + "')", 1000);
if(total < 0) clearTimeout(int);
}
})()
</script>
</head>
<body onLoad="timeCounter('timeCounter')">
<p id="timeCounter">01 : 00 : 00</p>
</body>
</html>
- 2 回答
- 0 关注
- 575 浏览
添加回答
举报