English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
: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).
$":nth-of-type(number|An+B|odd|even)
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 | Description |
---|---|
number | Index of each child element to be matched (from1Start) |
odd | Select every odd child element |
even | Select every even child element |
An+B | Specify the child element to be selected Example: p:nth-of-type(3n + 2Select every third element starting from the second paragraph |