childNodes

<html>
<head>
<title>getElementsByTagName()</title>
<script language="javascript">
function test1()
{
var ul=document.getElementById("bb");
alert(ul.childNodes.length);

for(var i=0;i<ul.childNodes.length;i++)
{
alert(ul.childNodes[i].nodeName);
}

}
</script>
</head>
<body onload="test1()">

<ul id="uu">
<a href="a1.html">a1</a>
<a href="a2.html">a2</a>
</ul>

<ul id="bb">
<a href="aa1.html">aa1</a>
<a href="aa2.html">aa2</a>
</ul>

</body>
</html>
IE8
a标签中间的文本算是 文本节点 测试弹出4 分别是: a #text a #text

你可能感兴趣的:(node)