好想說stop這個按鈕是有什么用
<!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 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 是一個按鈕,
onclick= "clearInterval(int)",
clearInterval() 就是取消計時器,計時器就停止了。
2016-05-05
按下stop會觸發clearInterval(int)這個事件,這個事件是停止JS中計時的方法!
2016-05-05
你點擊下,查看下時間還有在變化嗎
2016-05-05
按下STOP就停止計時