0
Q:

how to get a parent element of an element javascript

var parent = document.getElementById("myElement").parentElement; 
3
document.body.parentNode; // Returns the <html> element
document.body.parentElement; // Returns the <html> element

document.documentElement.parentNode; // Returns the Document node
document.documentElement.parentElement; // Returns null (<html> does not have a parent ELEMENT node) 
1

New to Communities?

Join the community