Jq 遍历 全选 全不选 反选
//全选 全不选
$('#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 遍历 全选 全不选 反选的更多相关文章
- 基于JQ的多选/全选/反选及获取选中的值
<!-- author:青芒 --> <!DOCTYPE html> <html lang="en"> <head> <met ...
- 利用jQuery实现CheckBox全选/全不选/反选
转自:http://www.cnblogs.com/linjiqin/p/3148259.html jQuery有些版本中实现CheckBox全选/全不选/反选会有bug,经测试jquery-1.3. ...
- js(四) 全选/全不选和反选
思路:通过选择全选的选框的状态stuts 即true/false控制其他选框. 首先 我们要通过.checked方法获取选框(全选/全不选)的值. function all(){ var stuts= ...
- Java 多选框的全选、多选、反选(JQuery 实现)
jQuery 实现全选.多选.反选 学习内容: 需求 总结: 学习内容: 需求 jQuery 实现全选.多选.反选 实现代码 <!DOCTYPE html> <html lang=& ...
- jquery 全选 全不选 反选
1.概述 在项目中经常遇到列表中对复选框进行勾选操作,全选...反选.. 2. example <html> <body> <form id="test-for ...
- jquery的全选/全不选/反选以及attr添加checked属性失败的解决办法
如下图: <head> <title></title> <style type="text/css"> div { border: ...
- JS实现全选、不选、反选
思路:1.获取元素.2.用for循环历遍数组,把checkbox的checked设置为true即实现全选,把checkbox的checked设置为false即实现不选.3.通过if判断,如果check ...
- springMvc接收ajax数组参数,以及jquery复选框选中、反选、全选、全不选
一.复选框选中.反选.全选.全不选 html代码: <input type='checkbox' name='menuCheckBox' value='10' >苹果 <input ...
- 【七】jquery之属性attr、 removeAttr、prop[全选全不选及反选]
全选全不选 界面: 代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...
随机推荐
- OSSEC
[科普]入侵检测系统ossec配置文件详解 http://www.freebuf.com/articles/system/11862.html http://www.freebuf.com/autho ...
- Palindrome Partitioning——LeetCode
Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...
- 关于开发板不能ping通外网IP
最近在做远程监控的项目,打算用开发板给一个网站发送数据包.不过发现开发板只能ping通同一局域网内的ip,外网的ip不能ping通.纠结了半天发现是网关没有设置的原因.下面来说说如何解决这个问题. 首 ...
- 15个不起眼但非常强大的 Vim 命令
如果我的关于这个话题的最新帖子没有提醒到你的话,那我明确地说,我是一个 vim 的粉丝.所以在你们中的某些人向我扔石头之前,我先向你们展示一系列“鲜为人知的 Vim 命令”.我的意思是,一些你可能以前 ...
- Extjs 4.2.0 MVC 架构
内容: 1. 文件结构 2. 创建项目 3. 定义控制器 4. 定义视图 5. 控制Grid 6. 创建Model和Store 7. 通过Model保存数据 8. 保存到服务器端 大型客户端程序通常都 ...
- java排序算法-选择排序
public class SelectionSort { private static void selectSortTest() { int[] sortArray = { 5, 2, 4, 1, ...
- 适配ios7
if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) { self.edgesForExtendedLayout = UIR ...
- 提高VS2010/VS2012编译速度
除了合理的划分模块,减少link的时间外,充分利用多核编译也很重要. VS2010/2012都可以用多核编译,需要同时设置如下两个参数: Enable Minimal Rebuild Propert ...
- Servlet的PrintWriter out = response.getWriter()使用
一直以来,只知道out可以向客户端浏览器页面输入数据(html.txt等类型),今天在和php程序联调时发现自己的理解出现了偏差. out是输出字符流,即servlet接受到request请求后,se ...
- VS2013配置文件常见问题解决方法
1.C++ VS2013出现LINK : fatal error LNK1104: 无法打开文件“kernel32.lib,”错误,什么原因啊?原因:项目->XX(项目名称)属性->链接器 ...