Element.parentElement (Property)

The element that is the owner or parent of the current object.


JScript - 3.0
Internet Explorer - 4.0
Property/method value type:Element object
JavaScript syntax:IEmyElement.parentElement

This is the object that contains the receiving Element object. For example, an Element object that represents a <TABLE> tag is the parentElement of the Element objects that represent the <TR> tags within that table. If you want to add a row to a table, you may select the row that needs to be replaced or that it can be inserted after. You can then locate its parent Element and modify that if necessary.

This is not the same as the offsetParent. This property reflects the true document hierarchy in all its fine detail. The offsetParent property reflects the spatial relationships between objects. Objects that show up in the parentElement hierarchy will likely be omitted from the offsetParent hierarchy model on account of them not contributing any spatial offset to the contained elements.

Access to a parent element is especially useful when driving the generation of styleSheet properties. You might have a series of nested containers which cascade a relative font size. By checking the fonts size property belonging to the style object associated with the parent Element, you can set a limit on this cascading effect to prevent the font sizes from becoming too small.

See also:Document object, Element object, Element.firstChild, Element.lastChild, Element.nextSibling, Element.offsetParent, Element.parentNode, Element.previousSibling, Hierarchy of objects

Property attributes:


insert figure 0043