domhelpers
DOMhelpers is a (very) small collection of some handy utility functions which help you query the DOM.
getClosest(element, selector)
Get the closest element from element
which matches selector
. This includes
the element
itself.
var el2 = document;console; // div.el1console; // div.el2
getParent(element, selector)
Get the closest element from element
which matches selector
. This does NOT
include the element
itself, instead it searches from the element
's parentNode.
var el2 = document;console; // div.el1console; // undefined
getParents(element, selector)
Get all parents from element
which match selector
. This function always
returns an array.
var el2 = document;console; // [div.el1, div.el1]console; // []