jQuery复选框

全选/全不选、全选、全不选、反选、提交

<script>
$(docunment).ready(function(){
      //全选
      $("#selectAll").change(function(){
        		$("input[name='items']").prop("checked",this.checked);
        	});
        	//全选
        	$("#checkedAll").click(function(){
        		$("input[name='items']").prop("checked",true);
        	});
        	//全不选
        	$("#checkedNo").click(function(){
        		$("input[name='items']").prop("checked",false);
        	});
        	//反选
        	$("#checkedRev").click(function(){
        		$("input[name='items']").each(function(){
        			this.checked=!this.checked;
        		});
        	});
        	//获得选项的值
        	$("#checkValue").click(function(){
        		var result="";
        		$("input[name='items']").each(function(){
        			if(this.checked){
        				result+=$(this).val()+"\n";
        			}
        		});
        		alert(result);
        	});
});
</script>

猜你喜欢

转载自blog.csdn.net/weixin_43750327/article/details/84826447