Селектор :nth-last-of-type()


nth-last-of-type selector

Описание: Selects all the elements that are the nth-child of their parent in relation to siblings with the same element name, counting from the last element to the first.

  • Добавлен в версии: 1.9jQuery( ":nth-last-of-type(index/even/odd/equation)" )

    index: The index of each child to match, starting with the last one (1), the string even or odd, or an equation ( eg. :nth-last-of-type(even), :nth-last-of-type(4n) )

Because jQuery's implementation of :nth- selectors is strictly derived from the CSS specification, the value of n is "1-indexed", meaning that the counting starts at 1. For other selector expressions such as :eq() or :even jQuery follows JavaScript's "0-indexed" counting. Given a single <ul> containing three <li>s, $('li:nth-last-of-type(1)') selects the third, last, <li>.

Further discussion of this usage can be found in the W3C CSS specification.