English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
:nth-last-of-The type() selector selects all elements of the given type based on their position among their sibling elements (starting from the end).
Using:nth-last-child()Selector, selects all elements of the specified type that are the nth child of their parent element, counting from the last child.
$(":nth-last-of-type(number|An+B|odd|even)
Starting from the end, select the nth child element of its parent element:4Each <span> element inside each <span> element:
-last-of-type(4).css("background", "lime"); });Test and see‹/›
Odd and even keywords are used to match child elements with odd or even indices:
-last-of-type(odd) -last-of-type(even) });Test and see‹/›
Parameter | Description |
---|---|
number | The index of each child element to be matched (from1End) |
odd | Select every odd child element |
even | Select every even child element |
An+B | Specify the child element to be selected Example: p:nth-last-of-type(3n + 2Starting from the second paragraph, select every third paragraph |