parentNode (W3C DOM Core property)

Version Depr. Static Read-only
DOM1 No No Yes
Browser support (more…)
IE6+ FF1.5+ SA1.3+ OP9+
Full Full Full Full


var parent = node.parentNode;

In the example above, the parent variable will be a reference to the parent of node, if it has one; otherwise it will be null.

So in this HTML example, if node refers to the q element, then parent will be a reference to the surrounding p:

<p><q>What know you of 'always'?</q> Marvin sighed.</p>


The parent of this node; or null if it has no parent.

Nodes which have just been created but not added to the document, or have just been removed from the document, or are Attr, Document, DocumentFragment or Entity nodes, do not have a parent.

This property is readonly.


Internet Explorer Firefox Safari Opera
5.5 6.0 7.0 1.5 2.0 3.0 1.3 2.0 3.0 9.0 9.5
Buggy Full Full Full Full Full Full Full Full Full Full

In Internet Explorer 5.5 in HTML the parentNode of an existing node that has no parent returns undefined, rather than null.

User-contributed notes

There are no comments yet.

Related Products