<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script type="text/javascript">
var se,h=0,m=0,s=0,ss=1;
function time_show(){
if((ss%100)==0) {s+=1;ss=1;}
if(s>0 && (s%60)==0) {m+=1;s=0;}
if(m>0 && (m%60)==0) {h+=1;m=0;}
var t=h+"时"+m+"分"+s+"秒"+ss+"毫秒";
document.getElementById("showTime").value=t;
ss++;
}
function startclock() {se=setInterval("time_show()",10);}
function pauseclock() {clearInterval(se);}
function stopclock() {clearInterval(se);ss=1;h=m=s=0;}
</script>
<input name="s" type="button" value="开始计时" onclick="startclock()" />
<input name="s" type="button" value="暂停计时" onclick="pauseclock()" />
<input name="s" type="button" value="停止计时" onclick="stopclock()" />
<input type="text" id="showTime" value="0时0分0秒0毫秒" />
</body>
</html>
为什么多次按“开始计时”按钮后,计时速度会加快,而且不能暂停计时了,这是怎么回事?
Best_4
走向流沙
随时随地看视频慕课网APP
相关分类