关于javascript的一个小问题

下面这个循环模块执行不出来:

 <!doctype html>
<html>

<body>
<p>点击下面的按钮,将代码执行5  次</p>
<button onClick="myFunction()">提交</button>
<p id="demo"></p>
<script>
function myFunction()
{
   var x=" ";
    for (var i=0;i<5;i++)
   {
   x=x+"the number is"+i+"<br>";
   }
   document.getElementBYId("demo").innerHTML=x;
}
</script>
</body>
</html>

document.getElementBYId 写错了 ,拼写错误

        window.onload= function myFunction() {
            var x=" "; 
            for (var i=0;i<5;i++) {
                x=x+"the number is"+i+"<br>"; 
            } 
            document.getElementById("demo").innerHTML=x; 
        }

ById 而不是 BYId

改成document.getElementById("demo");