Returns the parent element of the current node in the DOM hierarchy.
Newly created (createElement) and removed (removeChild) elements have no parent element in Firefox, Google Chrome, Opera, Safari and Internet Explorer from version 9. In older Internet Explorer versions, newly created elements have no parent but when the HTML content of a newly created element is modified (innerHTML, appendChild, etc.) the element is placed in a DocumentFragment node. Removed elements are also placed in a DocumentFragment node in Internet Explorer before version 9.
You can find the related objects in the Supported by objects section below.
This property is read-only.
Retrieves a reference to the parent object or null if the current node has no parent element.
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the parentNode property:
Did you find this example helpful?
User Contributed Comments