表格隔行换色、全选反选效果

2个月前 (03-18 15:45)阅读49回复0
大陆
大陆
  • 管理员
  • 发消息
  • 注册排名1
  • 经验值4189
  • 级别管理员
  • 主题837
  • 回复2
楼主

分享一款网站后台常用的js全选反选特效代码,列表中隔行换色显示,根据自己是需求自定义颜色代码即可。

<!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=gb2312">
<meta name="keywords" content="武鸣人网站,武鸣信息网,武鸣本地网,武鸣信息资源平台,减肥,健身,励志,励志语录,js特效,网页特效,www.wuming.ren">
<meta name="description" content="欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。">
<title>表格隔行换色、全选反选效果_武鸣人</title>
<style type="text/css">
body{
font-size:12px;
color:#366;
}
table{
border:none;
background:#fefefe;
width:100%;
border-collapse:collapse;
}
th{
background:#CFDEC6;
padding:4px;
color:#000;
}
td,.tdNormal{
border:#cfdec6 solid 1px;
padding:4px;
background:fefefe;
cursor:pointer;
}
.tdOdd{
background:#f1fefa;
}
.tdOver{
background:#F5FAF7;
}
.tdClick{
background:#64B495;
color:#000;
}
</style>
<script type="text/javascript" src="/img/jquery_wuming_ren.js"></script>
<script type="text/javascript">
$(function(){
$("table tr:even").addClass("tdOdd");
$("th:first").css("background","#B4C6C1");//首个
$("table tr").mouseover(function(){
$(this).addClass("tdOver");}).mouseout(function(){
$(this).removeClass("tdOver");}).click(function(){//荧光棒
$(".tdClick").removeClass("tdClick");$(this).addClass("tdClick");
})//行锁定
$("input:checkbox:first").click(function(){
$("input:checkbox:not(input:checkbox:first)").each(function(){//剔除本身
$(this).attr("checked",$("input:checkbox:first").attr("checked"));
})
})
$("input:checkbox:not(input:checkbox:first)").click(function(){
var flag=true;
$("input:checkbox:not(input:checkbox:first)").each(function(){
if(!this.checked){flag=false;}//不可使用if($(this).attr("checked","false")){flag=false;}
});
$("input:checkbox:first").attr("checked",flag);
})
});//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
</script>
</head>
<body>
<a href="https://www.wuming.ren">武鸣人</a>,各种信息资源免费发布,分享励志语录经典短句,减肥健身常识,各种js特效代码。网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)<hr>
<!--欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。-->
<script type="text/javascript" src="https://www.wuming.ren/ad/tc.js"></script>
<script type="text/javascript" src="https://www.wuming.ren/ad/a.js"></script>
需要加载js文件,请刷新后看效果。
<table>
  <tr>
    <th><input type="checkbox"></th>
    <th>姓名</th>
    <th>年龄</th>
    <th>专业</th>
  </tr>
  <tr>
    <td><input type="checkbox"></td>
    <td>王洪剑</td>
    <td>22</td>
    <td>武鸣人一号</td>
  </tr>
  <tr>
    <td><input type="checkbox"></td>
    <td>李川川</td>
    <td>20</td>
    <td>武鸣人二号</td>
  </tr>
  <tr>
    <td><input type="checkbox"></td>
    <td>陈超</td>
    <td>22</td>
    <td>武鸣人三号</td>
  </tr>
  <tr>
    <td><input type="checkbox"></td>
    <td>秦玉龙</td>
    <td>21</td>
    <td>武鸣人四号</td>
  </tr>
  <tr>
    <td><input type="checkbox"></td>
    <td>刘威</td>
    <td>21</td>
    <td>武鸣人五号</td>
  </tr>
  <tr>
    <td><input type="checkbox"></td>
    <td>张会会</td>
    <td>21</td>
    <td>武鸣人六号</td>
  </tr>
  <tr>
    <td><input type="checkbox"></td>
    <td>胡海生</td>
    <td>30</td>
    <td>武鸣人七号</td>
  </tr>
  <tr>
    <td><input type="checkbox"></td>
    <td>吴雄</td>
    <td>22</td>
    <td>武鸣人八号</td>
  </tr>
</table>
</body>
</html>


0
0
收藏0
回帖

表格隔行换色、全选反选效果 期待您的回复!

取消
载入表情清单……
载入颜色清单……
插入网络图片

取消确定

图片上传中
编辑器信息
提示信息