.find()
.find( selector )Returns: jQuery
Description: Get the descendants(子代) of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.
.find( selector )
-
selectorType: SelectorA string containing a selector expression to match elements against.
-
version added: 1.6.find( jQuery object )
-
jQuery objectType: ObjectA jQuery object to match elements against.
-
-
version added: 1.6.find( element )
-
elementType: ElementAn element to match elements against.
Given a jQuery object that represents a set of DOM elements, the
.find()
method allows us to search through the descendants of these elements in the DOM tree and construct a new jQuery object from the matching elements. The.find()
and.children()
methods are similar, except that the latter only travels a single level down the DOM tree.The first signature for the
.find()
method accepts a selector expression of the same type that we can pass to the$()
function. The elements will be filtered by testing whether they match this selector.Consider a page with a basic nested list on it:
-