//全选 全不选
$('#checkAll').click(function () {
//判断是否被选中
var bischecked = $('#checkAll').is(':checked');
var fruit = $('input[name="check"]');
bischecked ? fruit.attr('checked', true) : fruit.attr('checked', false);
}); //反选 遍历checkbox 如果当前为选中 就设置为 不选中 反之相同
$("#tabVouchList tr").each(function () {
if ($("td:eq(0) input[name='check']", $(this)).is(':checked')) {
$(this).attr('checked', false);
} else {
$(this).attr('checked', true);
}
});
   //attr 可能会出现 第二次全选没反应的情况   prop 完美解决
$("#checkall").bind("click", function () {
$("input[type='checkbox']").prop("checked", this.checked);
});

  

HTML table

        <table id="tabVouchList">
<tr>
<th>
<input type="checkbox" name="checkAll" />
</th>
<th>
行号
</th>
<th>
名称
</th>
</tr>
<tr>
<td>
<input type="checkbox" name="check" />
</td>
<td>
行号
</td>
<td>
名称
</td>
</tr>
</table>

Jq 遍历 全选 全不选 反选的更多相关文章

  1. 基于JQ的多选/全选/反选及获取选中的值

    <!-- author:青芒 --> <!DOCTYPE html> <html lang="en"> <head> <met ...

  2. 利用jQuery实现CheckBox全选/全不选/反选

    转自:http://www.cnblogs.com/linjiqin/p/3148259.html jQuery有些版本中实现CheckBox全选/全不选/反选会有bug,经测试jquery-1.3. ...

  3. js(四) 全选/全不选和反选

    思路:通过选择全选的选框的状态stuts 即true/false控制其他选框. 首先 我们要通过.checked方法获取选框(全选/全不选)的值. function all(){ var stuts= ...

  4. Java 多选框的全选、多选、反选(JQuery 实现)

    jQuery 实现全选.多选.反选 学习内容: 需求 总结: 学习内容: 需求 jQuery 实现全选.多选.反选 实现代码 <!DOCTYPE html> <html lang=& ...

  5. jquery 全选 全不选 反选

    1.概述 在项目中经常遇到列表中对复选框进行勾选操作,全选...反选.. 2. example <html> <body> <form id="test-for ...

  6. jquery的全选/全不选/反选以及attr添加checked属性失败的解决办法

    如下图: <head> <title></title> <style type="text/css"> div { border: ...

  7. JS实现全选、不选、反选

    思路:1.获取元素.2.用for循环历遍数组,把checkbox的checked设置为true即实现全选,把checkbox的checked设置为false即实现不选.3.通过if判断,如果check ...

  8. springMvc接收ajax数组参数,以及jquery复选框选中、反选、全选、全不选

    一.复选框选中.反选.全选.全不选 html代码: <input type='checkbox' name='menuCheckBox' value='10' >苹果 <input ...

  9. 【七】jquery之属性attr、 removeAttr、prop[全选全不选及反选]

    全选全不选 界面: 代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...

随机推荐

  1. poj 3026Borg Maze

    http://poj.org/problem?id=3026 #include<cstdio> #include<iostream> #include<cstring&g ...

  2. EMS-keil C51常用错误

    1. LAB100.C(12): error C216: subscript on non-array or too many dimensions 原程序如下: #include <reg51 ...

  3. 为什么同时需要IP地址和MAC地址

    每个以太网设备在出厂时都有一个唯一的MAC地址,为什么还需要为每台主机再分配一个IP地址?或者说每台主机都分配唯一的IP地址,为什么还要在网络设备(如网卡,集线器,路由器等)生产时内嵌一个唯一的MAC ...

  4. 【转】Java中本地时间的获取方法--不错

    原文网址:http://highforest.blog.51cto.com/125539/842496/ 熟悉Oracle数据库的人,应该知道:select to_char(sysdate,'yyyy ...

  5. 【转】ASCII码表在线查询

    原文网址:http://www.litefeel.com/tools/ascii.php ASCII码对照表 下表列出了字符集中的 0 - 127 (0x00 - 0x7F). 十进制 十六进制 字符 ...

  6. Sublime 2 Installation for Linux

    Linux You can download the package and uncompress it manually. Alternatively, you can use the comman ...

  7. HDOJ 1028 Ignatius and the Princess III(递推)

    Problem Description "Well, it seems the first problem is too easy. I will let you know how fool ...

  8. HDOJ 2092 整数解(2次方程整数解公式)

    Problem Description 有二个整数,它们加起来等于某个整数,乘起来又等于另一个整数,它们到底是真还是假,也就是这种整数到底存不存在,实在有点吃不准,你能快速回答吗?看来只能通过编程. ...

  9. 在DataTable和DataView中查找指定记录

    一.在DataTable中查找 1. 使用Select方法查找没有主键的表DataTable的Select方法返回一个DataRow数组,有四个重载的函数. DataRow[] drs = dt.Se ...

  10. java 全角字符半角字符转换

    /// <summary> /// 判断字符是否英文半角字符或标点 /// </summary> /// <remarks> /// 32    空格 /// 33 ...