当前位置: 首页 > 网络学院 > XML相关教程 > XML DOM > owner元素 属性
The ownerElement property returns the element node the attribute is attached to.
ownerElement 属性的作用是:返回指定属性所附属的元素节点。
attrObject.ownerElement |
In all examples, we will use the XML file books.xml, and the JavaScript function loadXMLDoc().
在所有案例中,我们将使用“books.xml”文件以及JavaScript 函数“loadXMLDoc()”。
The following code fragment returns the element node the first category attribute is attached to:
下面的代码片断将返回第一个“category”属性所附属的元素节点:
xmlDoc=loadXMLDoc("books.xml"); var 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); |
The output of the code above will be:
上述代码将输出下面的结果:
[object Element] book 1 |
ownerElement - Get the element node an attribute is attached to
ownerElement - 获取属性所附属的元素节点