-
Book Overview & Buying
-
Table Of Contents
jQuery 1.4 Reference Guide
The following selectors were added to the jQuery library in an attempt to address common DOM traversal needs not met by the CSS specification.
Select the element at index n within the matched set.
$('li:eq(2)') selects the third <li> element
$('.myclass:eq(1)') selects the second element with the class myclass
The selector :nth(n) exists as a synonym of this selector.
The index-related selector expressions (including this selector and the others that follow) filter the set of elements that have matched the expressions that precede them. They narrow the set down based on the order of the elements within this matched set. For example, if elements are first selected with a class selector (.myclass) and four elements are returned, these elements are given indices 0 through 3 for the purposes of these selectors.
Note that since JavaScript arrays use 0-based indexing, these selectors reflect that fact. This is why $('.myclass:eq...
Change the font size
Change margin width
Change background colour