//得到所有check
1 var c = $(this).parent().find('input:checkbox'); 2 if (c.is(':checked')) { 3 var role = {}; 4 role.RoleGroupID = groupId.toString(); 5 role.MenuCode = $(this).data('menucode'); 6 role.OperationCode = $(this).data('perationcode'); 7 json.push(role); 8 i++; 9 }
1 //直接得到选中的check 2 if ($(this).parent().find('input:checkbox:checked'))
1 全选checkbox 2 <ul id = "list-unstyled" class="list-unstyled"> 3 <li><input name="check" type="checkbox" value="9-DM"></li> 4 <li><input name="check" type="checkbox" value="10-DM"></li> 5 <li><input name="check" type="checkbox" value="11-DM"></li> 6 <li><input name="check" type="checkbox" value="12-DM"></li> 7 </ul> 8 9 $('input[type="checkbox"]').prop('checked', 'true')
1 //反选checkbox 2 $('input[name="check"]').each(function () { 3 $(this).prop("checked", !$(this).prop("checked")); 4 });