-
Book Overview & Buying
-
Table Of Contents
jQuery 1.4 Reference Guide
These methods use the structure of the DOM tree to locate a new set of elements.
Get the descendants of each element in the current set of matched elements filtered by a selector.
.find(selector)
selector: A string containing a selector expression to match elements against
The new jQuery object.
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 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 as follows:
<ul class="level-1"> <li class="item-i">I</li> <li class...
Change the font size
Change margin width
Change background colour