jquery checkbox的使用

获取单个checkbox选中的写法:
$('input:checkbox:checked').val();
$("input:[type='checkbox']:checked").val();
$('input:[name='ck']:checked').val(); 
获取多个checkbox的选中项
$('input:checkbox').each(function(){      if($(this).attr('checked')==true){ 
   alert($(this).val()); 
  }})
设置第一个checkbox为选中值$('input:checkbox:first').attr('checked','checked'); 
或者
$('input:checkbox').eq(0).attr("checked",true);
根据索引设置任意一个checkbox为选中值
$('input: checkbox').eq(索引值).attr('checked',true);
或者
$('inut:radio').slice(1,2).attr('checked,true'); 
根据Value的值设置checkbox为选中值$("input:checkbox[value='ss']").attr('check','true');
删除Value为1的checkbox$("input:checkbox[value='ss']").remove();
删除第几个checkbox$('input:checkbox').eq(索引值).remove()
索引值=0,1,2,,
全选Checkbox
$('input:checkbox').each(function() {
        $(this).attr('checked', true);                                                
});

检查checkbox是否选中

    $("input[name='ssgao']").prop('checked'); 返回true/false
    var flag = $("input[name='ssgao']").get(0).checked;返回true/false
原文地址:https://www.cnblogs.com/ssgao/p/8868656.html