Name
parentElement — NN n/a IE 4 DOM n/a
Synopsis
Read-only
Returns a reference to the next outermost element in the HTML
containment hierarchy. An element’s HTML parent is not
necessarily the same as the object returned by the
offsetParent property. The
parentElement concerns itself strictly with source
code containment, while the offsetParent property
looks to the next outermost element that is used as the coordinate
system for measuring the location of the current element. For
example, if the main document contains a P element
with an EM element nested inside, the
EM element has two parents. The
P element is the returned
parentElement value (due to the HTML source code
containment), while the BODY element is the
returned offsetParent value (due to coordinate
space containment).
You can jump multiple parent levels by cascading
parentElement properties, as in:
document.all.elementID.parentElement.parentElementYou can then use references to access a parent element’s properties or methods.
Example
document.all.elementID.parentElement.style.font-size = "14pt"Value
Element object reference.
Default
None.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access