Easy Tutorial
❮ Traversing Next Misc Deferred Isrejected ❯

jQuery :nth-of-type() Selector

jQuery Selectors

Example

Select each <p> element that is the third <p> element of its parent:


Definition and Usage

The :nth-of-type(*n*) selector selects all elements that are the nth child of their parent in relation to siblings with the same element name.

Tip: Use the :nth-child() selector to select all elements that are the nth child of their parent, regardless of type.


Syntax

Parameter Description
n The index of each child to match. <br> <br> It must be a number. The first element has an index of 1. <br>
even Selects every even child element.
odd Selects every odd child element.
formula Specifies which child elements to select by formula (an + b). <br> Example: p:nth-of-type(3n+2) selects every third paragraph starting from the second.

Try it - Examples

Select each <p> element that is the second <p> element of each <div> element

Select child elements using the formula (an + b)an +b )

Use "even" and "odd"

Differences between :nth-child(), :nth-last-child(), :nth-of-type(), and :nth-of-last-type()


jQuery Selectors

❮ Traversing Next Misc Deferred Isrejected ❯