為什么點(diǎn)了一次start 在點(diǎn)stop就沒有了反應(yīng)
<!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;
? ?}
// 每隔100毫秒調(diào)用clock函數(shù),并將返回值賦值給i
? ? ?var i=setInterval("clock()",1000);
function rec(){var i=setInterval("clock()",1000);}</script>
</head>
<body>
? <form>
? ? <input type="text" id="clock" size="50"? />
? ? <input type="button" value="Stop" onclick="clearInterval(i)"? />
? <input type="button" value="start" onclick="rec()"></form>
</body>
</html>
2019-02-27
function rec(){var i=setInterval("clock()",1000);}</script>? ?var 去掉就可以了