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 |
|---|---|---|---|---|
| 0 | 13607 | alphons | https://en.ans.wiki/765/how-to-get-parent-node-of-an-element-in-javascript | 1 |
| 1 | 11891 | en | https://en.ans.wiki/765/how-to-get-parent-node-of-an-element-in-javascript | 6 |