<!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");
}
}); });

jquery checkbox选框操作的更多相关文章

  1. jQuery——复选框操作

    学习jQuer对表单.表格操作的过程中,按照书上的例子发现一个问题: <!DOCTYPE html> <html> <head> <title>复选框应 ...

  2. jquery 复选框操作-prop()的使用

    <!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...

  3. jquery复选框操作

    $('input[type="checkbox"]').change(function(e) { var checked = $(this).prop("checked& ...

  4. Jquery全选系列操作(锋利的jQuery)

    Jquery全选系列操作(锋利的jQuery) <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" ...

  5. C#:复选框操作类

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...

  6. Jquery复选框

    Jquery复选框 1.checkbox list选择 代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//E ...

  7. JS及Dom练习 | 模态对话框及复选框操作

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. Selenium之勾选框操作

    勾选框操作:       所谓勾选框,意思是可以勾选一个及以上或全部勾选.勾选框的图标一般都是方形的. 复选框勾选一般分为三种情况: ①勾选单个框,我们直接用元素定位的方式定位到点击即可. ②勾选多个 ...

  9. Thymeleaf+layui+jquery复选框回显

    一.Thymeleaf+layui+jquery复选框回显 基于Thymeleaf模板下的layui+jquery复选框回显,主要是jquery.大致意思是:把数组转成JSON传到前台,再在前台转回数 ...

随机推荐

  1. 《Unix内核源码剖析》

    <Unix内核源码剖析> 基本信息 作者: (日)青柳隆宏 译者: 殷中翔 丛书名: 图灵程序设计丛书 出版社:人民邮电出版社 ISBN:9787115345219 上架时间:2014-2 ...

  2. CRF 及CRF++ 安装与解释

    CRF简介 Conditional Random Field:条件随机场,一种机器学习技术(模型) CRF由John Lafferty最早用于NLP技术领域,其在NLP技术领域中主要用于文本标注,并有 ...

  3. 【BZOJ】【2878】【NOI2012】迷失游乐园

    树形+基环树DP/数学期望 然而我并不会做…… 题解戳这里:http://blog.csdn.net/u011265346/article/details/46328543 好吧先考虑一个简单点的,当 ...

  4. 【BZOJ】【3489】A simple rmq problem

    KD-Tree(乱搞) Orz zyf教给蒟蒻做法 蒟蒻并不会这题正解……(可持久化树套树?...Orz 对于每个点,我们可以求出pre[i],nex[i],那么询问的答案就是:求max (a[i]) ...

  5. Linux学习杂记

    近期一口气看完了韩顺平老师讲的Linux视频教程,自己也在学习的过程中做了些笔记,记载例如以下.希望帮助到一些喜欢研究Linux的同学.也算是在云端备份一下笔记吧.以免电脑出现不可控的因素而遗失自己的 ...

  6. 用wubi安装的Ubuntu在重装Windows 7系统后,如何恢复(转)

    原文链接:双系统Win7+Ubuntu,重装Win7后找不到Ubuntu启动引导项问题 1.把安装ubuntu->winboot文件夹下wubidr和wubidr.mbr两个文件拷到C盘根目录下 ...

  7. 第二十四章 springboot注入servlet

    问:有了springMVC,为什么还要用servlet?有了servlet3的注解,为什么还要使用ServletRegistrationBean注入的方式? 使用场景:在有些场景下,比如我们要使用hy ...

  8. Scala中_(下划线)的常见用法

    Scala中_(下划线)的常见用法 地址:https://www.jianshu.com/p/0497583ec538

  9. Godaddy ssl续费更新问题总结

    之前客户在Godaddy 上购买的ssl证书过期了,但客户续费后打开https时却提示证书过期了 进行Godaddy 后台看到证书确实是过期的 但在账户里也确实看到ssl续费成功了 猜想可能是ssl续 ...

  10. [Algorithm] Find first missing positive integer

    Given an array of integers, find the first missing positive integer in linear time and constant spac ...