<!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. Eclipse点不出方法了

    window→preferences→java→editor→Content Assist→Advanced 然后选中右上方的所有 右下方选中一个即可.

  2. tornado基础入门(一)——简单了解tornado

    参考:http://demo.pythoner.com/itt2zh/ch1.html tornado是一个轻量级的web框架,是一个用python写的web服务器,它有三个最大的特点(优势)速度.简 ...

  3. python限制进程、子进程占用内存大小、CPU时间的方法:resource模块

    内置模块:resource 在mac环境下功能会存在问题.linux下可以使用:但是for i in range(10000)的值必须是10000或者更大的数值才有用.没有搞清楚为什么 #/usr/b ...

  4. 我所遭遇过的游戏中间件--Havok

    我所遭遇过的游戏中间件--Havok Havok是我接触的第一款游戏中间件,那是在五,六年前,我刚刚毕业,对游戏开发还是个菜鸟.我记得先是对游戏场景中的地形和其他静态物体生成刚体,然后做角色的Ragd ...

  5. [10] 圆管(Pipe)图形的生成算法

    顶点数据的生成 bool YfBuildPipeVertices ( Yreal radius, Yreal assistRadius, Yreal height, Yuint slices, YeO ...

  6. [leetcode]Sort List @ Python

    原题地址:http://oj.leetcode.com/problems/sort-list/ 题意:链表的排序.要求:时间复杂度O(nlogn),空间复杂度O(1). 解题思路:由于题目对时间复杂度 ...

  7. 错误: 找不到或无法加载主类 Files\red5-server ,原因与解决办法

    因为你把 red5放到了 Program Files 下,而Program Files 中间有个空格,启动路径不允许有空格,换个没空格的路径就OK啦

  8. 如何开机就启动node.js程序

      npm install -g qckwinsvc 定位到安装目录,node_modules/.bin/ 运行如下命令: > qckwinsvc prompt: Service name: [ ...

  9. 如何监控执行的SQL语句?

    环境: SQL Server 2012. 打开SQL Server Profiler. 在菜单中选择New Trace, 连接上SQL Server. 在弹出的窗口中选择Event selection ...

  10. Faiss学习:一

    在多个GPU上运行Faiss以及性能测试 一.Faiss的基本使用 1.1在CPU上运行 Faiss的所有算法都是围绕index展开的.不管运行搜索还是聚类,首先都要建立一个index. import ...