问答详情
源自:9-8 访问子节点childNodes

为什么没有输出??

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>无标题文档</title>

</head>

<body>

<div>

  javascript  

  <p>javascript</p>

  <div>jQuery</div>

  <h5>PHP</h5>

</div>

<script type="text/javascript">

 var fnod=document.getElementsTagName("div")[0].childNodes;

 for(var i=0;i<fnod.length;i++)

 {  document.write("节点类型:"+fnod[i].nodeName+" "+fnod[i].nodeType+" "+fnod[i].nodeValue+"<br/>");

         

     }

 

</script>

</body>

</html>


提问者:stay123 2015-01-25 14:34

个回答

  • stay123
    2015-01-25 14:36:56

    知道了。。。少了By