DOM Node.parentNode Property
The parentNode property returns the parent of a node in the DOM tree.
Description
The read-only parentNode property returns the node's parent, which can be an element, the document or a document fragment. It's null for nodes that haven't been added to the page. parentElement is similar but returns null when the parent isn't an element. To find a specific ancestor, closest() is usually more convenient.
Because the property is read-only, you move a node to a new parent by inserting it there with a method such as append(). To walk up through every ancestor, repeat node = node.parentNode until it's null.
Inside a shadow root, the top element's parentNode is the shadow root itself, not the host element; use the shadow root's host property to step out to the element it's attached to.
Syntax
node.parentNodeValue
The parent node, or null if the node has no parent.
Example
Browser Support
The following information will show you the current browser support for the Node.parentNode property. Hover over a browser icon to see the version that first introduced support for this property.
Desktop





Tablets & Mobile





