:even and :odd
匹配集合中为偶数或是奇数元素的元素集合。索引以0开始。返回匹配元素集合
<script src="lib/jquery.js" type="text/javascript"></script>
$(document).ready(function(){
// alert("congratulation!");
$(".stripe tr").mouseover(function(){
$(this).addClass("over");
}).mouseout(function(){
$(this).removeClass("over");
});
$(".stripe tr:even").addClass("alt");
});
</script>
<table class="stripe" width="400" border="0" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>姓名</td>
<th>年龄</td>
<th><p>Mail</p>
</td>
</tr>
</thead>
<tbody>
<tr>
<td>wangdingjun</td>
<td>22</td>
<td>xuyin3530@yahoo.com.cn</td>
</tr>
<tr>
<td>蜗牛</td>
<td>30</td>
<td>leon3530@126.com</td>
</tr>
<tr>
<td>Snail</td>
<td>24</td>
<td>wangdingjun0@gmail.com</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>