Skip to main content Accessibility Feedback

Traversing the DOM

Element.parentNode

Get the parent of an element.

var elem = document.querySelector('#some-elem');
var parent = elem.parentNode;

You can also string them together to go several levels up.

var levelUpParent = elem.parentNode.parentNode;

Works back to at least IE6.