<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="box">
</div>
<script type="text/javascript">
var num=0;
var timer = setInterval(a,1000);
function a(){
num++;
document.body.innerHTML += num + '<br/>';
if(num>=10){
clearInterval(timer)
}
}
</script>
</body>
</html>