start 一次,stop 是可以停住得,但是連續(xù) start 之后,就 stop 停不住了,怎么回事呢?
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>定時(shí)器</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>
2018-09-03
編輯器的問題喲,放在webstorm里運(yùn)行是好的