Skip to main content Accessibility Feedback

Traversing the DOM

Element.parentNode

Get the parent of an element.

<div id="app">
	<h1>Hello, world!</h1>
</div>
let h1 = document.querySelector('h1');

// returns the #app element
let parent = h1.parentNode;