: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>
本文介绍了一种使用jQuery实现表格中偶数行自动添加样式的方法,并通过鼠标悬停效果增强用户体验。具体实现了当鼠标悬停在表格行上时,该行会显示高亮效果。
547

被折叠的 条评论
为什么被折叠?



