Sometimes, we want to get the parent div of an element with JavaScript.
In this article, we’ll look at how to get the parent div of an element with JavaScript.
How to get the parent div of an element with JavaScript?
To get the parent div of an element with JavaScript, we use the parentNode
property.
For instance, we write
const parentDiv = pDoc.parentNode;
to get the parent node of the pDoc
element with pDoc.parentNode
.
Conclusion
To get the parent div of an element with JavaScript, we use the parentNode
property.