这个代码在这个课堂不能停止时间有点坑,通过编辑器倒是可以什么情况?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>语句筛选练习</title>
</head>
<body>
<form>
<input type="text" id="clock" size="50" />
<input type="button" value="Stop" onclick="clearInterval(i)" />
</form>
<script>
function clock(){
var time=new Date();
attime = time.getHours()+":"+time.getMinutes()+":"+time.getSeconds();
document.getElementById("clock").value = time;
}
// 每隔100毫秒调用clock函数,并将返回值赋值给i
var i=setInterval("clock()",100);
</script>
</body>
</html>