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"> ...
随机推荐
- 感兴趣的Linux发行版
1. Ubuntu,包括KUbuntu,XUbuntu,Kyrin等等 2. BluestarLinux - 基于Arch Linux,感觉很美 http://sourceforge.net/proj ...
- linux浏览器,邮件客户端,输入法,双屏设置,应用软件,scrot -s截图,office
搜狗输入法linux版:http://pinyin.sogou.com/linux/help.php win/linux同时支持比较好用的浏览器:maxthon,firefox,maxthon,ope ...
- Hadoop InputFormat
Hadoop可以处理不同数据格式(数据源)的数据,从文本文件到(非)关系型数据库,这很大程度上得益于Hadoop InputFormat的可扩展性设计,InputFormat层次结构图如下:
- oracle触发器使用总结
1.说明 1)触发器是一种特殊的存储过程,触发器一般由事件触发并且不能接受参数,存储器由语句块去调用 2)触发器分类: 1.DML触发器: 创建在表上,由DML事件引发 2.instead of触发器 ...
- C# 中dataTable中的数据批量增加至数据表中
/// <summary> /// 批量添加 /// </summary> /// <param name="dt"></param> ...
- Best Time to Buy and Sell Stock II ——LeetCode
Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...
- iOS--导航栏样式
push返回按钮样式: UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBar ...
- linux用户权限相关命令
1.创建组 groupadd test 修改组 groupmod -n test2 test 将名字改为test2 删除组 groupdel test 查看组 groups r ...
- 解决git提交问题error: The requested URL returned error: 403 Forbidden while accessing
git提交代码时,出现这个错误"error: The requested URL returned error: 403 Forbidden while accessing https&qu ...
- Qt Style Sheets Reference
Qt Style Sheets support various properties, pseudo-states, and subcontrols that make it possible to ...