even

英[ˈi:vn] 美[ˈivən]

adv.Even; even; even; more; coincidentally at...time

adj. Fair; flat; even; average

vt. Make flat; make equal

vi. Flatten; become equal

jquery even selector syntax

Function::The even selector selects every element with an even index value (such as 2, 4, 6). Index values ​​start at 0, and all first elements are even numbers (0). The most common usage: Used with other elements/selectors to select even-numbered elements in a specified group (such as the example above).

Syntax: $(":even")

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

jquery even 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:even").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