Entry
How do I use the method parent?
How do I use the method parent?
Apr 11th, 2005 04:58
Martin Honnen,
The method parent takes no argument and returns the parent XML object of
this XML object or null if there is no parent. In E4X the parent of an
XML attribute is the element the attribute is attached to.
Here are some examples:
var gods = <gods type="usenet">
<god>
<name>Kibo</name>
</god>
</gods>;
alert(gods.parent()); // shows 'null'
alert(gods..name[0].parent().name()); // shows 'god'
alert(gods.@type.parent().name()); // shows 'gods'