Описание: Select the element at index
n within the matched set.
Добавлен в версии: 1.0jQuery( ":eq(index)" )
index: Zero-based index of the element to match.
Добавлен в версии: 1.8jQuery( ":eq(-index)" )
indexFromEnd: Zero-based index of the element to match, counting backwards from the last element.
The index-related selectors (
:odd) 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
3 for the purposes of these selectors.
$( ".myclass:eq(1)" ) selects the second element in the document with the class myclass, rather than the first. In contrast,
:nth-child(n) uses 1-based indexing to conform to the CSS specification.
Prior to jQuery 1.8, the
:eq(index) selector did not accept a negative value for
index (though the
.eq(index) method did).
:eq()is a jQuery extension and not part of the CSS specification, queries using
:eq()cannot take advantage of the performance boost provided by the native DOM
querySelectorAll()method. For better performance in modern browsers, use