<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../js/jquery-1.8.2.js"></script>
</head>
<body>
<table border="1" align="center">
<tr>
<th>状态</th>
<th>用户名</th>
</tr>
<tr>
<td><input type="checkbox"/></td>
<td>赵</td>
</tr>
<tr>
<td><input type="checkbox"/></td>
<td>钱</td>
</tr>
<tr>
<td><input type="checkbox"/></td>
<td>孙</td>
</tr>
<tr>
<td><input type="checkbox"/></td>
<td>李</td>
</tr>
<tr>
<td><input type="checkbox"/></td>
<td>周</td>
</tr>
<tr>
<td><input type="button" value="全选中"/></td>
<td><input type="button" value="全取消"/></td>
<td><input type="button" value="全反选"/></td>
</tr>
</table>
<script type="text/javascript">
//页面加载时,将全取消按钮失效
window.onload = function(){
$(":button:eq(1)").attr("disabled","disabled");
}
//全选中
$(":button:eq(0)").click(function(){
//所有复选框设置为选中状态
$(":checkbox").attr("checked","checked");
//将该按钮失效
$(this).attr("disabled","disabled");
//将全取消按钮生效
$(":button:eq(1)").removeAttr("disabled");
});
//全取消
$(":button:eq(1)").click(function(){
//所有选中的复选框删除选中属性
$(":checkbox:checked").removeAttr("checked");
//将该按钮失效
$(this).attr("disabled","disabled");
//将全选中按钮生效
$(":button:eq(0)").removeAttr("disabled");
});
//全反选
$(":button:eq(2)").click(function(){ //将选中的失效
$(":checkbox:checked").attr("disabled","disabled"); //将未选中的选中
$(":checkbox:not(:checked)").attr("checked","checked"); //将失效的生效,同时删除选中属性
$(":checkbox:disabled").removeAttr("disabled").removeAttr("checked"); });
</script>
</body>
</html>

全反选或者

     $(":button:eq(2)").click(function(){
$(":checkbox").each(function(){
if($(this).attr("checked")!=null)
{
$(this).removeAttr("checked");
}
else
{
$(this).attr("checked","checked");
}
}); });

最新文章

  1. python多线程学习记录
  2. mysql 删除重复数据保留只保留一条
  3. Codeforces Round #260 (Div. 2) C
  4. scst使用的一些问题
  5. fastcgi(一)
  6. phpmyadmin安装教程及配置设置
  7. show variables 详解
  8. PHP面向对象之旅:抽象类继承抽象类(转)
  9. pcduino通过sd卡刷系统
  10. [j2ee][IDEA properties中文乱码解决]
  11. Windows Azure功能更新:Oracle软件正式登陆Azure了
  12. 初次接触VC++载入自己定义LIB 即静态链接
  13. QT在Windows控制台下输出
  14. [leetcode-474-Ones and Zeroes]
  15. 基于POI和DOM4将Excel(2007)文档写进Xml文件
  16. Java之IO流进阶篇:内存流,打印流,对象流
  17. Java框架之Struts2(五)
  18. Docker(十九)-Docker监控容器资源的占用情况
  19. java-jdbc数据库连接
  20. fengsuo

热门文章

  1. Struts2 校验框架学习笔记
  2. MAC之查看日历
  3. 我所遭遇过的游戏中间件--FlashOcx
  4. multiple definition of 问题解决方法
  5. Largest Rectangle in Histogram leetcode java
  6. js实现trim() JS去掉首尾空格 JS去掉两头空格
  7. Android之AlarmManager
  8. (转)初识 Lucene
  9. [转] 公司局域网中代码访问 github.com
  10. (转)Unity中protobuf的使用方法