要想实现重置后,再点start重新从0开始计数而不是按重置前的数接着计数,reCount函数怎么写?
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>计时器</title>
</head>
<script type="text/javascript">
var num=0;
var i;
function startCount(){
document.getElementById('count').value=num;
num=num+1;
i=setTimeout("startCount()",1000);//i为全局变量
}
function stopCount(){
clearTimeout(i);
}
function reCount(){
document.getElementById('count').value=0;
//这里应该怎么写???
}
</script>
</head>
<body>
<form>
<input type="text" id="count" />
<input type="button" value="Start" onclick="startCount()" />
<input type="button" value="Stop" onclick="stopCount()" />
<input type="button" value="Reset" onclick="reCount()" />
</form>