jQuery :nth-of-type()Selector
Examples
Select each <p> element that is the third <p> element of its parent:
Try it Yourself »
Definition and Usage
:nth-of-type(n) selector selects the Nth of a specific type of its parentnchild element of all elements.
Tip:Please use the:nth-child()selector to select elements of its parentregardless of typethat are thenchild element of all elements.
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 | Selects every even child element. |
| odd | Selects every odd child element. |
| formula | Specifies which child element is to be selected via the formula (an + b) to select. Example: p:nth-of-type(3n+2) selects every third paragraph, starting from the second paragraph. |
Try it Yourself - Examples
Select each <p> element that is the second <p> element of a <div> element.
How to select each <p> element that is the second <p> element of a <div> element.
Using the formula (an + b)
How to use the formula (an + b) to select different child elements.
Using "even" and "odd"
How to use even and odd to select different child elements.
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 Selector