Easy Tutorial
❮ Jquery Dimensions Event Scroll ❯

jQuery :nth-last-of-type() Selector

jQuery Selectors

Example

Selects every <p> element that is the third <p> element of its parent, counting from the last child:


Definition and Usage

The :nth-last-of-type(*n*) selector selects all elements that are the nth child of their parent in a specific type, counting from the last child.

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


Syntax

Parameter Description
n The index of each child element to match. <br> <br> 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 using a formula (an + b). <br> Example: p:nth-last-child(3n+2) selects every third paragraph, starting from the second-to-last paragraph.

Try It - Examples

Selects every <p> element that is the first <p> element of each <div> element, counting from the last child

Using a formula (an + b) to select different <p> elements, counting from the last child.

Using "even" and "odd"

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


jQuery Selectors

❮ Jquery Dimensions Event Scroll ❯