好想說(shuō)stop這個(gè)按鈕是有什么用
<!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 int = setInterval(clock,100);
</script>
</head>
<body>
? <form>
? ? <input type="text" id="clock" size="50" ?/>
? ? <input type="button" value="Stop" onclick="clearInterval(int)" />
? </form>
</body>
</html>
2016-05-05
stop 是一個(gè)按鈕,
onclick= "clearInterval(int)",
clearInterval() 就是取消計(jì)時(shí)器,計(jì)時(shí)器就停止了。
2016-05-05
按下stop會(huì)觸發(fā)clearInterval(int)這個(gè)事件,這個(gè)事件是停止JS中計(jì)時(shí)的方法!
2016-05-05
你點(diǎn)擊下,查看下時(shí)間還有在變化嗎
2016-05-05
按下STOP就停止計(jì)時(shí)