setTimeout()计时器,在载入后延迟指定时间后,去执行一次表达式,仅执行一次。不是只执行一次么??
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>计时器</title>
</head>
<script type="text/javascript">
var num=0;
function startCount() {
document.getElementById('count').value=num;
num=num+1;
setTimeout("startCount()",1000);
}
//执行一次就完了啊,为什么是无限循环,用按钮跟这行再写setTimeout 有什么区别??
</script>
</head>
<body>
<form>
<input type="text" id="count" />
<input type="button" value="Start" onClick="startCount()" />
</form>
</body>
</html>