属性节点在DOM2中不算作子节点吗?
属性节点在DOM中不算作子节点吗 我的页面在正文中是这样的:text>h1>text>div>text>//结束5个孩子 但是属性节点不重要吗?childNodes属性不应该返回所有类型节点的数组吗?使用文本>属性>文本>h1>属性>文本>div>属性>文本>p//等 我有这一页:属性节点在DOM2中不算作子节点吗?,dom,Dom,属性节点在DOM中不算作子节点吗 我的页面在正文中是这样的:text>h1>text>div>text>//结束5个孩子 但是属性节点不重要吗?childNodes属性不应该返回所有类型节点的数组吗?使用文本>属性>文本>h1>属性>文本>div>属性>文本>p//等 我有这一页: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>DOM testing</title>
<script src="scripts/domTesting3.js" type="text/javascript" charset="utf-8"></script>
</head>
<body bgcolor="#cccccc">
<h1 id="test">Test</h1>
<div id="content">
<p>Examining the DOM2 Core and DOM2 HTML Recommendations</p>
<h2>Browsers</h2>
<ul id="browserList">
<li id="chromeListItem">
<a href="http://www.google.com/chrome/ "title="Get Chrome" id="chrome">Chrome</a>
</li>
<li id="firefoxListItem">
<a href="http://www.getfirefox.com/"title="Get Firefox" id="firefox">Firefox 5.0</a>
</li>
<li>
<a href="http://www.microsoft.com/windows/ie/downloads/" title="Get Microsoft Internet Explorer" id="msie">Microsoft Internet Explorer 9</a>
</li>
<li>
<a href="http://www.apple.com/macosx/features/safari/" title="Check out Safari" id="safari">Safari</a>
</li>
<li>
<a href="http://www.opera.com/download/" title="Get Opera" id="opera">Opera 9</a>
</li>
</ul>
</div>
</body>
</html>
使用此脚本:
function domTest() {
var le = document.body.childNodes.length;
alert(le);//alerts 5 children where are attribut nodes?
for(i = 0; i < le; i++) {
alert(document.body.childNodes[i].nodeType);
alert(document.body.childNodes[i].nodeName);
alert(document.body.childNodes[i].nodeValue);
}
}
window.onload = domTest;
AtTrar对象继承节点接口,但由于它们实际上不是它们描述的元素的子节点,DOM不认为它们是文档树的一部分。因此,节点属性parentNode、previousSibling和nextSibling对于Attr对象具有空值
从