XML DOM ownerElement 屬性
Attr 對象
定義和用法
ownerElement 屬性返回屬性所附屬的元素節(jié)點。
語法
實例
下面的代碼片段使用 loadXMLDoc() 把 "books.xml" 載入 xmlDoc 中,并返回第一個 category 元素所附屬的元素節(jié)點:
實例
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 對象
更多建議: