Селектор :gt()


Содержание:

gt selector

Описание: Select all elements at an index greater than index within the matched set.

  • Добавлен в версии: 1.0jQuery( ":gt(index)" )

    index: Zero-based index.

  • Добавлен в версии: 1.8jQuery( ":gt(-index)" )

    indexFromEnd: Zero-based index, counting backwards from the last element.

index-related selectors

The index-related selector expressions (including this "greater than" selector) 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:gt(1)" ) selects elements after the second element in the document with the class myclass, rather than after the first. In contrast, :nth-child(n) uses 1-based indexing to conform to the CSS specification.

Prior to jQuery 1.8, the :gt(index) selector did not accept a negative value for index

Дополнительные замечания:

  • Because :gt() is a jQuery extension and not part of the CSS specification, queries using :gt() cannot take advantage of the performance boost provided by the native DOM querySelectorAll() method. For better performance in modern browsers, use $("your-pure-css-selector").slice(index) instead.