大神们求解答啊!为什么是这样的?遍历节点出问题了!
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>节点属性</title> </head> <body> <ul> <li>javascript</li> <li>HTML/CSS</li> <li>jQuery</li> </ul> <script type="text/javascript"> node = document.getElementsByTagName("li"); var type = ['元素','属性','文本',,,,,'注释','文档']; document.write("节点的数量为:"+node.length+"<br>"); for (var i in node){ each = node[i]; document.write("节点名称:"+each.nodeName+"\t\t"); document.write("节点属性:"+each.nodeValue+"\t\t"); document.write("节点类型:"+type[each.nodeType]+"<br>") } </script> </body> </html>
输出显示节点数是三个,但是后面遍历节点的时候结果是这样的:
后面那三行是怎么回事啊啊啊啊!!!