
定义和用法
ownerElement 属性返回属性所附属的元素节点。
语法
attrObject.ownerElement
实例
下面的代码片段使用 loadXMLDoc() 把 "books.xml" 载入 xmlDoc 中,并返回第一个 category 元素所附属的元素节点:
实例
xmlDoc=loadXMLDoc("books.xml"); x=xmlDoc.getElementsByTagName('book'); document.write(x.item(0).attributes[0].ownerElement); document.write("<br>"); document.write(x.item(0).attributes[0].ownerElement.nodeName); document.write("<br>"); document.write(x.item(0).attributes[0].ownerElement.nodeType);
上面的代码将输出:
[object Element] book 1
