為什么不會(huì)停止時(shí)間呢?
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>計(jì)時(shí)器</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>
2020-02-12
我復(fù)制了代碼,然后粘貼到了自己的編輯器上運(yùn)行是可以停止的;可能是網(wǎng)頁版的編輯器有問題吧~
2020-07-07
var i=setInterval(clock,1000);應(yīng)為var i=setInterval("clock()",1000);
2020-06-29
chrome一樣停不了
2020-05-28
火狐和opera就不行
2020-05-05
我的是谷歌流浪器,也不會(huì)停止
2020-03-06
剛開始寫著 瀏覽器版本不同 效果也不同的
2020-02-12
點(diǎn)擊下stop才會(huì)停止哦