jQuery :nth-last-of-type() Selector
Example
Select the third
element of every
element that is the third child of its parent, counting from the last child:
$("p:nth-last-of-type(3)")
Try it »
Definition and Usage
:nth-last-of-type(n) selector selects all elements that are the n child of their parent, counting from the last child.
Tip:Please use the :nth-last-child() selector to select theregardless of typechild of n child of their parent, counting from the last child.
Syntax
:nth-last-of-type(
n
|even|odd|
formula
)
| Parameters | Description |
|---|---|
| n | The index of each child element to be matched. |
必须是一个数字。第一个元素的索引号是 1。 |
| even | Selects every even child element. | | odd | Selects every odd child element. | | formula | Specifies which child elements to select via the (an + b) to select. Example: p:nth-last-child(3n+2) selects every third element, starting from the second-to-last element. |
Try it - Example
element of every
elements, counted starting from the last child
How to select all
element of every
element, counting from the last child.
Using the formula (an + b)
How to use the formula (an + b) to select different
element, counting from the last child.
Using "even" and "odd"
How to use even and odd to select different child elements, counting from the last child.
Difference between :nth-child(), :nth-last-child(), :nth-of-type(), and :nth-last-of-type()
Difference between p:nth-child(2), p:nth-last-child(2), p:nth-of-type(2), and p:nth-last-of-type(2).
jQuery selector