jquery的table隔行变色、复选框的选择变色
2012-03-26 22:07
288 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>parent</title>
<style>
.even{
background-color:#0FF;
}
.odd{
background-color:#F9F;}
.selected{
background:#CCC;
}
.selected1{
background-color:#99F;
}
</style>
<script src="../jquery/jquery-1.7.1.js"></script>
<script>
$(document).ready(function(){
$("tr:even").addClass("even");
$("tr:odd").addClass("odd");
$("input[type=checkbox]").hover(function(){
$(this).parents("tr").toggleClass("selected1");
});
$("input[type=checkbox]").click(function (){
// alert("ddd");
// if($("input[type=checkbox]:checked")){
//alert($("input[type=checkbox]:checked").length);
$(this).parents("tr").toggleClass("selected");
//}else{
//$(this).parent("tr").removeClass("selected");
//}
});
// $(this).toggleClass("selected");
});
</script>
</head>
<body>
<table width="500" border="1">
<tr>
<td> </td>
<td>姓名</td>
<td>班级</td>
<td>E-mail</td>
</tr>
<tr>
<td><input type="checkbox" class="ck" name="ck" /></td>
<td>马丹玲</td>
<td>php</td>
<td>1223312</td>
</tr>
<tr>
<td><input type="checkbox" class="ck" name="ck" /></td>
<td>聂彦池</td>
<td>php</td>
<td>3574789</td>
</tr>
<tr>
<td><input type="checkbox" class="ck" name="ck" /></td>
<td>李楠</td>
<td>php</td>
<td>345645</td>
</tr>
<tr>
<td><input type="checkbox" class="ck" name="ck" /></td>
<td>齐小松</td>
<td>php</td>
<td>54765</td>
</tr>
<tr>
<td><input type="checkbox"class="ck" name="ck" /></td>
<td>马浩鹏</td>
<td>php</td>
<td>3769088</td>
</tr>
<tr>
<td><input type="checkbox" class="ck" name="ck" /></td>
<td>宋凯</td>
<td>php</td>
<td>3554853</td>
</tr>
<tr>
<td><input type="checkbox" name="ck" /></td>
<td>丁延</td>
<td>php</td>
<td>46485</td>
</tr>
</table>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>parent</title>
<style>
.even{
background-color:#0FF;
}
.odd{
background-color:#F9F;}
.selected{
background:#CCC;
}
.selected1{
background-color:#99F;
}
</style>
<script src="../jquery/jquery-1.7.1.js"></script>
<script>
$(document).ready(function(){
$("tr:even").addClass("even");
$("tr:odd").addClass("odd");
$("input[type=checkbox]").hover(function(){
$(this).parents("tr").toggleClass("selected1");
});
$("input[type=checkbox]").click(function (){
// alert("ddd");
// if($("input[type=checkbox]:checked")){
//alert($("input[type=checkbox]:checked").length);
$(this).parents("tr").toggleClass("selected");
//}else{
//$(this).parent("tr").removeClass("selected");
//}
});
// $(this).toggleClass("selected");
});
</script>
</head>
<body>
<table width="500" border="1">
<tr>
<td> </td>
<td>姓名</td>
<td>班级</td>
<td>E-mail</td>
</tr>
<tr>
<td><input type="checkbox" class="ck" name="ck" /></td>
<td>马丹玲</td>
<td>php</td>
<td>1223312</td>
</tr>
<tr>
<td><input type="checkbox" class="ck" name="ck" /></td>
<td>聂彦池</td>
<td>php</td>
<td>3574789</td>
</tr>
<tr>
<td><input type="checkbox" class="ck" name="ck" /></td>
<td>李楠</td>
<td>php</td>
<td>345645</td>
</tr>
<tr>
<td><input type="checkbox" class="ck" name="ck" /></td>
<td>齐小松</td>
<td>php</td>
<td>54765</td>
</tr>
<tr>
<td><input type="checkbox"class="ck" name="ck" /></td>
<td>马浩鹏</td>
<td>php</td>
<td>3769088</td>
</tr>
<tr>
<td><input type="checkbox" class="ck" name="ck" /></td>
<td>宋凯</td>
<td>php</td>
<td>3554853</td>
</tr>
<tr>
<td><input type="checkbox" name="ck" /></td>
<td>丁延</td>
<td>php</td>
<td>46485</td>
</tr>
</table>
</body>
</html>
相关文章推荐
- jQuery实现table隔行换色和鼠标经过变色的两种方法
- jQuery实现table隔行换色和鼠标经过变色
- 【JavaScript&jQuery】单选框radio,复选框checkbox,下拉选择框select
- jQuery实现复选框全选/取消全选/反选及获得选择的值
- jQuery实现复选框全选/全部取消/反选/获得选择的值
- 用jquery实现复选框主从选择
- jQuery中的几个案例:隔行变色、复选框全选和全不选
- jquery学习笔记(4)--实现table隔行变色以及单选框选中
- jQuery:1.5.4.4,表格变色(单击行,把当行的复选框(checkbox)设为选中状态,并应用当前样式)
- jQuery实现复选框成对选择及对应取消的方法
- jQuery实现复选框成对选择及对应取消的方法
- 表单选择时变色jquery实现
- 用js或Jquery实现table隔行变色以…
- jQuery+SpringMVC中的复选框选择与传值实例
- jQuery实现table隔行换色和鼠标经过变色的两种方法
- jQuery实现table隔行换色和鼠标经过变色
- jQuery获取复选框被选中数量及判断选择值的方法详解
- jQuery实现table隔行换色和鼠标经过变色
- jQuery复选框成对选择,对应取消功能
- 用jquery实现复选框主从选择