為什么停不下來,而且setInterval里的1000調了沒反應
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>計時器</title>
<script type="text/javascript">
? ?function clock(){
? ? ? var time=new Date();? ? ? ? ? ? ? ? ??
? ? ? document.getElementById("clock").value = time;
? ?}
? ? var i=setInterval("clock()",1000);
</script>
</head>
<body>
? <form>
? ? <input type="text" id="clock" size="50"? />
? ? <input type="button" value="Stop" onclick="clearInterval(i)" />
? </form>
</body>
</html>
2022-07-21
您好,剛才我試了下您的代碼是可以停下來的,您可能設置了自動運行。他一直卡在了之前的一秒一下,需要刷新頁面吧代碼都寫完,在運行試試