jQuery :nth-last-of-type()Selector
Example
Select every <p> element that is the third <p> element of its parent, counting from the last child:
Try it yourself »
Definition and Usage
:nth-last-of-type(n) selector selects, of a specific type of its parent, thennth child element among all elements, counting from the last child.
Tip:Please use:nth-last-child()selector to select elements belonging to its parentregardless of typethennth child element among all elements, counting from the last child.
Syntax
| Parameter | Description |
|---|---|
| n | The index of each child element to match. Must be a number. The index number of the first element is 1. |
| even | Select every even child element. |
| odd | Select every odd child element. |
| formula | Specifies which child element is to be selected via the formula (an + b) to select. Example: p:nth-last-child(3n+2) selects every third paragraph, starting from the second-to-last. |
Try it yourself - Example
Select every <p> element that is the first <p> element of all <div> elements, counting from the last child.
How to select every <p> element that is the first <p> element of all <div> elements, counting from the last child.
Using the formula (an + b)
How to use the formula (an + b) to select different <p> elements, 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.
The difference between :nth-child(), :nth-last-child(), :nth-of-type(), and :nth-of-last-type()
The difference between p:nth-child(2), p:nth-last-child(2), p:nth-of-type(2), and p:nth-of-last-type(2).
Other Extensions
jQuery Selectors