我的正確答案
<!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()",100);
?????
?? function Stop(){
?????? window.clearInterval(i);
?? }
</script>
</head>
<body>
? <form>
??? <input type="text" id="clock" size="50"? />
??? <input type="button" value="Stop" onclick="clearInterval(i)"?? />
? </form>
</body>
</html>
2018-10-31
可以定義stop函數(shù) 但是如果你要停止函數(shù)外面的值 你就需要傳入值給需要調(diào)用的函數(shù)
所以你在stop函數(shù)傳入一個(gè)i 然后調(diào)用stop函數(shù)也是一樣的
function Stop(i){
?????? window.clearInterval(i);
?? }
2018-10-17
不需要定義stop()函數(shù)啊