XML DOM ownerElement 屬性
Attr 對(duì)象
定義和用法
ownerElement 屬性返回屬性所附屬的元素節(jié)點(diǎn)。
語(yǔ)法
實(shí)例
下面的代碼片段使用 loadXMLDoc() 把 "books.xml" 載入 xmlDoc 中,并返回第一個(gè) category 元素所附屬的元素節(jié)點(diǎn):
實(shí)例
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book');
document.write(x.item(0).attributes[0].ownerElement);
document.write("
");
document.write(x.item(0).attributes[0].ownerElement.nodeName);
document.write("
");
document.write(x.item(0).attributes[0].ownerElement.nodeType);
上面的代碼將輸出:
[object Element]
book
1
嘗試一下 ?
Attr 對(duì)象
更多建議: