jQuery获取未选中的checkbox

jQuery获取未选中的checkbox $(‘input[type=checkbox]’).not(“input:checked”);

jquery判断checked的三种方法.attr(‘checked’): //看版本1.6+返回:“checked"或"undefined” ;1.5-返回:true或false
.prop(‘checked’): //16+:true/false
.is(‘:checked’): //所有版本:true/false//别忘记冒号哦

jQuery获取选中的checkbox$(‘input[type=checkbox]:checked’);

html代码
篮球

足球

排球

网球

壁球

乒乓球

羽毛球



JS代码function setVal(iNum){
var aForm = document.getElementById(“myForm”);
var aArr = aForm.hobby;
for(var i=0;i<aArr.length;i++){
if( iNum<0 ){
aArr[i].checked = !aArr[i].checked;
}else{
aArr[i].checked = iNum;
}
}
}

设置选中下边两种写法没有任何区别 只是少了些代码而已

jquery赋值checked的几种写法:
所有的jquery版本都可以这样赋值:
// $(“#cb1”).attr(“checked”,“checked”);
// $(“#cb1”).attr(“checked”,true);

jquery1.6+:prop的4种赋值:
// $(“#cb1”).prop(“checked”,true);//很简单就不说了哦
// $(“#cb1”).prop({checked:true}); //map键值对
// KaTeX parse error: Expected 'EOF', got '#' at position 3: ("#̲cb1").prop("che…(“#cb1”).prop(“checked”,“checked”);

为什么input checkbox有 checked='checked’还是没选中
如果用jQuery1.6+来写的话:
建议使用
$(element).prop(‘checked’, true/false);
而不是
$(element).attr(‘checked’, true/false);
其实也就相当于要使用:
element.checked = true/false;
而并不是
element.setAttribute(‘checked’, true/false/‘checked’);

jquery判断checked的三种方法.attr(‘checked’): //看版本1.6+返回:“checked"或"undefined” ;1.5-返回:true或false
.prop(‘checked’): //16+:true/false
.is(‘:checked’): //所有版本:true/false//别忘记冒号哦

jQuery获取未选中的checkbox $(‘input[type=checkbox]’).not(“input:checked”);

jQuery获取选中的checkbox$(‘input[type=checkbox]:checked’);

jquery官网checked的用法http://api.jquery.com/checked-selector/

DataTable翻页checked部分代码
内容太多需要勾选时,我们需要做翻页,但是翻页要记录之前的页面勾选了哪些,需要借助input来记录。html代码如下:

<%@ page language=“java” import=“java.util.*” pageEncoding=“UTF-8”%>
<%@ taglib prefix=“c” uri=“http://java.sun.com/jsp/jstl/core” %>
<%@ taglib uri=“http://java.sun.com/jsp/jstl/fmt” prefix=“fmt”%>
<%@ taglib prefix=“shiro” uri=“http://shiro.apache.org/tags” %>
<%@ taglib uri=“http://java.sun.com/jsp/jstl/functions” prefix=“fn”%>
<%@ taglib uri=“com.data.web.view.function” prefix=“cf”%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+“😕/”+request.getServerName()+“:”+request.getServerPort()+path+“/”;
%>

参考文献 保 存

	<input class="form-control" type="hidden" id='checkList' >
	<div class="row">
		<div class="col-md-12">
			<div class="panel panel-default">
				<div class="panel-heading">参考文献列表</div>
				<div class="panel-body">
					<div class="table-responsive">
						<table
							class="table table-striped table-bordered responsive table-hover"
							id="table" cellspacing="0" width="100%">
							<thead>
								<tr>
									<th width="8%" class="min-mobile-l">期刊名</th>
									<th width="20%" class="desktop">标题</th>
									<th width="10%" class="min-mobile-l">作者</th>
									<th width="10%" class="min-mobile-l">摘要</th>
									<th width="10%" class="min-mobile-l">引用</th>
								</tr>
							</thead>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
<!-- Morris Chart Js 
<script src="assets/js/morris/raphael-2.1.0.min.js"></script>
<script src="assets/js/morris/morris.js"></script>-->
<!-- Custom Js 
<script src="assets/js/custom-scripts.js"></script>-->
 <!-- DATA TABLE SCRIPTS -->
<script src="/assets/js/dataTables/jquery.dataTables.js"></script>
<script src="/assets/js/dataTables/dataTables.bootstrap.js"></script>
<script src="/plugins/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="/plugins/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值