settimeout 回调函数

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>

<script type="text/javascript">
window.onload=function(){
var btn=document.getElementById("btn");
var num=document.getElementById("num");
var a=0;
btn.onclick=function(){

function addNumber(){
num.value=a;
a++;
setTimeout(addNumber,1000);
}
addNumber();
}

}
</script>

</head>

<body>


<input type="button" id="btn" value="点击增加">
<input type="text" id="num">

</body>
</html>

原文地址:https://www.cnblogs.com/gxw123/p/7424447.html