start 一次,stop 是可以停住得,但是连续 start 之后,就 stop 停不住了,怎么回事呢?
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>定时器</title>
<script type="text/javascript">
var attime;
var i;
function clock1(){
i = setInterval(function(){
var time=new Date();
document.getElementById("clock").value = time},1000);
}
</script>
</head>
<body onload="clock1()">
<form>
<input type="text" id="clock" size="50" />
<input type="button" name="stop" value="stop" onclick="clearInterval(i)">
<input type="button" name="start" value="start" onclick="clock1()">
</form>
</body>
</html>