December 2013
Intermediate to advanced
384 pages
9h 54m
English
$("p.menu").closest("div"); //selects the closest <div> ancestor for <p> //elements that have class="menu"
The .closest(selector,[context] or object or element) method returns a jQuery object representing the first element that matches the argument that is passed in. The argument can be a selector, a selector with context of where to begin searching, a jQuery object, or a DOM object. The search begins at the current set of elements and then searches ancestors.
Read now
Unlock full access