plainJS

Functions / Traversing

Get parent element node

jQuery $.parent(), $.parents()

2015 page

This is the original page from 2015, kept at its address while the tested rewrite is in progress. The code is of its time: it ran in Internet Explorer and does not use what browsers have gained since. The rewrite replaces it here.

In short

Getting the parent DOM node of an element.

Selecting the parent node of an element via cross-browser safe DOM method:

js
var el = document.querySelector('div');
var parent = el.parentNode;