English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery :nth-of-type() Selector

jQuery Selectors

:nth-of-The type() selector selects all elements of a given type based on their position among their sibling elements in a group.

Using:nth-child()Selectors can select all elements based on their position among all elements (regardless of their type).

Syntax:

$":nth-of-type(number|An+B|odd|even)

Example

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

  -of-type(3).css("background", "lime");
});
Test to see‹/›

Odd and even keywords are used to match child elements with odd or even indices:

  -of-type(odd)
  -of-type(even)
});
Test to see‹/›

Parameter Value

ParameterDescription
numberIndex of each child element to be matched (from1Start)
oddSelect every odd child element
evenSelect every even child element
An+BSpecify the child element to be selected
Example: p:nth-of-type(3n + 2Select every third element starting from the second paragraph

jQuery Selectors