jquery-选择checkbox的多种策略

checkbox属性:
var val = $("#checkAll").val();// 获取指定id的复选框的值  
var isSelected = $("#checkAll").attr("checked"); // 判断id=checkAll的那个复选框是否处于选中状态,选中则isSelected=true;否则isSelected=false;  
$("#checkAll").attr("checked", true);// or  
$("#checkAll").attr("checked", 'checked');// 将id=checkbox_id3的那个复选框选中,即打勾  
$("#checkAll").attr("checked", false);// or  
$("#checkAll").attr("checked", '');// 将id=checkbox_id3的那个复选框不选中,即不打勾  
$("input[name=subBox][value=3]").attr("checked", 'checked');// 将name=subBox, value=3 的那个复选框选中,即打勾  
$("input[name=subBox][value=3]").attr("checked", '');// 将name=subBox, value=3 的那个复选框不选中,即不打勾  
$("input[type=checkbox][name=subBox]").get(2).checked = true;// 设置index = 2,即第三项为选中状态  
$("input[type=checkbox]:checked").each(function(){ //由于复选框一般选中的是多个,所以可以循环输出选中的值  
    alert($(this).val());  
}); 

转自:https://zhidao.baidu.com/question/2119243279183884227.html

原文地址:https://www.cnblogs.com/YangK-java/p/6233756.html