<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="timeshow" style="border: dashed 1px black; 20% ; height: 40px;">00时00分00秒</div>
<br />
<input type="button" onclick="startTime()" value="开始"/>
<input type="button" onclick="stopTime()" value="结束"/>
<input type="button" onclick="clearTime()" value="清零"/>
</body>
<script type="text/javascript">
var minute=0,hour=0,seconds=0;
var timeout;
function startTime(){
mark=0;
var date=new Date();
seconds++;
if(seconds>60){
seconds=0;
minute++;
if(minute>60){
minute=0;
hour++;
}
}
document.getElementById("timeshow").innerHTML=hour+"时"+minute+"分"+seconds+"秒";
timeout=setTimeout("startTime()",1000);
}
function stopTime(){
if(timeout!=""){
clearTimeout(timeout) ;
}
}
function clearTime (){
document.getElementById("timeshow").innerHTML="00时00分00秒";
clearTimeout(timeout) ;
}
</script>
</html>