jquery通过prop来对checkbox进行全选
来源:互联网 发布:软件测试人员培训 编辑:程序博客网 时间:2024/05/07 18:44
jquery判断checked的三种方法:
.attr(‘checked’): //看版本1.6+返回:”checked”或”undefined” ;1.5-返回:true或false
.prop(‘checked’): //16+:true/false
.is(‘:checked’): //所有版本:true/false
jquery赋值checked的几种写法:
所有的jquery版本都可以这样赋值:
// $(“#cb1″).attr(“checked”,”checked”);
// $(“#cb1″).attr(“checked”,true);
jquery1.6+:prop的4种赋值:
// $(“#cb1″).prop(“checked”,true);
// $(“#cb1″).prop({checked:true}); //map键值对
// $(“#cb1″).prop(“checked”,function(){
return true;//函数返回true或false
});
$(“#cb1″).prop(“checked”,”checked”);
function chAll(ch_id){
if($('input[name="ck_all"]').prop("checked")){
$('input[name="'+ch_id+'"]').prop("checked",true);
}else{
$('input[name="'+ch_id+'"]').prop("checked",false);
}
<table class="table table-hover table-bordered">
<thead>
<th width="4%"><input type="checkbox" name="ck_all" onclick="chAll('ck_id');"/></th>
<th width="5%">序号</th>
<th width="20%">姓名</th>
<th width="10%">年龄</th>
<th width="10%">性别</th>
<th width="30%">备注</th>
<th width="10%">操作</th>
</thead>
<tbody>
<c:forEach items="${page.list}" var="user" varStatus="status">
<tr>
<td><input type="checkbox" name="ck_id" value="${user.id}"/></td>
<td>${(status.index+1)+page.pageSize*(page.pageNumber-1)}</td>
<td><a href="javascript:void(0);" onclick="jumpToFrame('/user/show/${user.id}-readonly');">${user.name }</a></td>
<td>${user.age }</td>
<td>${user.sex==1?'男':'女' }</td>
<td>${user.remark }</td>
<td>
<button type="button" class="btn btn-primary btn-sm" onclick="locationHref('${ctx}/user/show/${user.id }');">修改</button>
<button type="button" class="btn btn-danger btn-sm" onclick="locationHref('${ctx}/user/del/${user.id }');">删除</button>
</tr>
</c:forEach>
</tbody>
</table> 0 0
- jquery通过prop来对checkbox进行全选
- GridView中通过js对CheckBox进行全选
- 对checkbox进行全选操作
- jQuery使用prop设置checkbox全选、反选
- jQuery使用prop设置checkbox全选、反选
- jQuery prop全选
- jquery对checkbox实现全选效果
- Jquery对checkbox操作,全选,取值
- jquery 使用attr方法对checkBox进行全选和反选操作
- jquery通过prop函数验证checkbox是否选中
- jquery系列之prop、attr以及对checkbox的操作
- 用JS(JavaScript)来进行对Struts的Html:checkbox或者html:multibox进行全选、及其他控制
- jquery .prop()的相关操作——全选、反选、获得所有选中的checkbox
- jQuery--checkbox全选/取消全选
- jQuery--checkbox全选/取消全选
- jQuery--checkbox全选/取消全选
- jquery checkbox全选取消全选
- jQuery--checkbox全选/取消全选
- poj2573
- noip提高组写题心得——动态规划4例
- Linux各目录作用
- 本博客已搬迁
- Ubuntu 安装mysql和简单操作
- jquery通过prop来对checkbox进行全选
- 算法导论之动态规划
- laravel实现上传文件类型判断
- touch事件的分发机制
- 【Android测试】AndroidStudio通过UIAutomator进行测试
- GCC 4.6 warning: variable set but not used
- WIFEXITED/WEXITSTATUS/WIFSIGNALED
- 位置信息重置类
- C++访问ORACLE数据库