English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The :odd selector selects each element with an odd index number (for example:1,3,5)
The index number starts from 0, so the index number of the first element is 0 (not1)
This is usually used with another selector to select each odd-indexed element in a group (as shown in the following example).
Use:evenThe selector selects elements with even index numbers.
$":odd")
Select odd rows, matching the second, fourth, etc. (index1,3,5etc):
$("document").ready(function(){ $("tr:odd").css("background", "coral"); });Test and See‹/›
Select odd list items, matching the second, fourth, etc. (index1,3,5etc):
$("document").ready(function(){ $("li:odd").css("background", "coral"); });Test and See‹/›