odd

英[ɒd] 美[ɑ:d]

adj. Weird; odd; remaining; temporary

n. Strange thing; weird thing; [golf] more than one shot of the opponent

jquery odd selector syntax

Function::odd selector selects each element with an odd index value (such as 1, 3, 5). Index values ​​start at 0, and all first elements are even numbers (0). The most common usage: used with other elements/selectors to select odd-numbered elements in a specified group (like the example above).

Syntax: $(":odd")

Notes: Please use the :even selector to select even-numbered elements .

jquery odd selector example

<html>
<head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript"> 
 
$(document).ready(function(){
    $("tr:odd").css("background-color","#B2E0FF");
});
 
</script>	
 
</head>
<body>
<html>
<body>
<h1>Welcome to My Web Page</h1>

<table>
<tr>
<th>Id</th>
<th>LastName</th>

<th>FirstName</th>
<th>Address</th>
<th>City</th>
</tr>

<tr>
<td>1</td>
<td>Adams</td>
<td>John</td>
<td>Oxford Street</td>

<td>London</td>
</tr>

<tr>
<td>2</td>
<td>Bush</td>
<td>George</td>
<td>Fifth Avenue</td>
<td>New York </td>
</tr>

<tr>
<td>3</td>
<td>Carter</td>
<td>Thomas</td>
<td>Changan Street</td>
<td>Beijing</td>
</tr>
<tr>
<td>4</td>
<td>Obama</td>
<td>Barack</td>
<td>Pennsylvania Avenue</td>
<td>Washington</td>
</tr>
</table>
</body>
</html>
</body>
</html>
Run instance »

Click the "Run instance" button to view the online instance