彼岸花开111
2016-08-25 18:10
<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>计时器计数</title>
<script type="text/javascript">
var num = 0;
var i;
function starcount(){
document.getElementById("txt").value = num;
num = num + 1;
i=setTimeout("starcount()",1000);
}
//setTimeout("starcount()",1000);
function stopcount(){
clearTimeout(i);
}
</script>
</head>
<body>
<form>
<input type="text" id="txt" />
<input type="button" value="start" onclick="startcount()" />
<input type="button" value="stop" onclick="stopcount()" />
</form>
</body>
</html>
//setTimeout("starcount()",1000);
在你设置的这个函数里 startcount 拼写错误 少了个 "t"
JavaScript进阶篇
468194 学习 · 21891 问题
相似问题