How to get parent node of an element in JavaScript?
In JavaScript , the attribute element.parentNode
returns the parent node of element
. Let's consider the following HTML code:
<div id="daddy">
<div id="child">
</div>
</div>
The following JavaScript code returns the parent element of the node child
, i.e. the node daddy
.
parent = document.getElementById('child').parentNode;
In JavaScript , the attribute element.parentNode
returns the parent node of element
. Let's consider the following HTML code:
<div id="daddy">
<div id="child">
</div>
</div>
The following JavaScript code returns the parent element of the node child
, i.e. the node daddy
.
parent = document.getElementById('child').parentNode;
In JavaScript , the attribute element.parentNode
returns the parent node of element
. Let's consider the following HTML code:
<div id="parent">
<div id="child">
</div>
</div>
The following JavaScript code returns the parent element of the node child
.
parent = document.getElementById('child').parentNode;
# | ID | Query | URL | Count |
---|