<body>
<table width=80% border="1">
   <thead>
          <th>姓名</th>
  <th>年龄</th>
   </thead>
   <tr align="left">
          <td>张三</td>
  <td>25</td>
    </tr>
</table>
<script language="javascript">
document.write("html的根节点为:"+document.childNodes[0].nodeName+"<br />");
document.write("根节点下面最后一个子节点为:"+document.childNodes[0].lastChild.nodeName+"<br />");
document.write("输出BODY节点下的第一个节点为:"+document.body.childNodes[0].nodeName+"<br />");
document.write("输出BODY节点下的第二个节点为:"+document.body.childNodes[1].nodeName+"<br />");
document.write("输出BODY节点下的第二个节点的类型为:"+document.body.childNodes[1].nodeType+"<br />");
</script>
</body>

解决方案 »

  1.   

    <html>
    <head>
    <title></title>
    </head>
    <body> 
    <table   width=80%   border="1"> 
          <thead> 
                        <th> 姓名 </th> 
        <th> 年龄 </th> 
          </thead> 
          <tr   align="left"> 
                        <td> 张三 </td> 
        <td> 25 </td> 
            </tr> 
    </table> 
    <script   language="javascript"> 
    document.write("html的根节点为:"+document.childNodes[0].nodeName+" <br   />"); 
    document.write("根节点下面最后一个子节点为:"+document.childNodes[0].lastChild.nodeName+" <br   />"); 
    document.write("输出BODY节点下的第一个节点为:"+document.body.childNodes[0].nodeName+" <br   />"); 
    document.write("输出BODY节点下的第二个节点为:"+document.body.childNodes[1].nodeName+" <br   />"); 
    document.write("输出BODY节点下的第二个节点的类型为:"+document.body.childNodes[1].nodeType+" <br   />"); 
    </script> 
    </body> 
    </html>
    html的根节点为:HTML 
    根节点下面最后一个子节点为:BODY 
    输出BODY节点下的第一个节点为:TABLE 
    输出BODY节点下的第二个节点为:SCRIPT 
    输出BODY节点下的第二个节点的类型为:1