1. Home
  2. Javascript
  3. Find closest element

Finds and selects the closest parent element to the selected one. It will check all elements all the way to the document root.

#javascript#select
element.closest('.nav');
copy
Full Javascript cheatsheet