当前位置: 代码迷 >> JavaScript >> 求教大神 appendChild错哪了
  详细解决方案

求教大神 appendChild错哪了

热度:82   发布时间:2012-10-17 10:25:47.0
求教大神 appendChild哪里错了啊
HTML code
<html>
    <head>
    <script>
    window.onload=function(){
    var b=document.getElementsByTagName("body");
    
    var d = document.createElement("div");

    b.appendChild(d)
    }
    </script>
    </head>
    <body >
    
    </body>
<html>


------解决方案--------------------
getElementsByTagName也得这样使用
var b=document.getElementsByTagName("body")[0];