1 <script language="javascript">
2 $(document).ready(function(){
3 //各行换色
4 $('table tr:odd').addClass('tr_odd'); //奇数行
5 $('table tr:even').addClass('tr_even'); //偶数行
6 //单击行选中是事件
7 $("tr").bind("click",function(){
8 if( $(this).hasClass('selected') ){
9 $(this).removeClass('selected')
10 .find(":checkbox").attr("checked",false);
11 }else{
12 $(this).addClass('selected')
13 .find(":checkbox").attr("checked",true);
14 }
15 })
16 //全选事件
17 $("#selectAll").click(function(){
18 $(":checkbox").attr("checked","checked");
19 });
20 //反选事件
21 $("#unSelect").click(function(){
22 var checkbox=$(":checkbox");
23 for(var i=0;i<checkbox.length;i++){
24 checkbox[i].checked=!checkbox[i].checked;
25 }
26 });
27 //取消事件
28 $("#cancelSelect").click(function(){
29 $(":checkbox").removeAttr("checked");
30 });
31
32
33 });