希望是一个简单的,但我无法从for循环打印出一个数字系列,回到HTML.看下面我的代码,当我点击按钮时,它只返回10,但不是其他数字 - 我哪里错了?
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Try It</button>
<p id="number"></p>
<script>
function myFunction() {
for (i=0; i<11; i++) {
document.getElementById("number").innerHTML=i+"</br>";
}
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)