慕村2012223
2018-11-12 17:47
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>计时器</title>
<script type="text/javascript">
var num=0;
function startCount() {
document.getElementById('count').value=num;
num=num+1;
setTumeout("startCount()",1000);
}
startCount();
</script>
</head>
<body>
<form>
<input type="text" id="count" />
</form>
</body>
</html>
var num = 0;
startCount();
function startCount() {
document.getElementById("count").value = num;
var s = setTimeout(function(){
num++;
startCount();
clearTimeout(s);
},1000);
}
在<input>后面加上<button onClick="startCount() ">click me</button>就可以了
错误有点多哦
setTumeout了你
函数外的不是调用函数是调setTimeout('startCount()',1000);
JavaScript进阶篇
468060 学习 · 21891 问题
相似问题
回答 3
回答 4