//获取所有的checkbox
$("input[type='checkbox']");
$("input[name='cb']");
//获取所有选中的checkbox
$('input:checkbox:checked');
$('input:[type='checkbox']:checked');
$('input[type='checkbox']:checked');
$('input:[name='test']:checked');
//获取checkbox的值
$('#checkbox').val();
//获取多个选中的checkbox的值
var vals = [];
$('input:checkbox:checked').each(function(index,item){
vals.push($(this).val());
});
//判断checkbox是否选中 (jquery 1.6以前版本 用 $(this).attr("checked"));
$('#checkbox').click(function(){
if($(this).prop('checked')){
alert('选中');
}else{
alert('没有选中');
};
});
//设置checkbox为选中状态
$('input:checkbox').attr('checked','checked');
$('input:checkbox').attr('checked',true);
//设置checkbox为不选中状态
$('input:checkbox').attr('checked',false);
$('input:checkbox').attr('checked','');
//设置checkbox为禁用状态(jquery<1.6用attr,jquery>=1.6建议用prop)
$("input[type='checkbox']").attr("disabled", "disabled");
$("input[type='checkbox']").attr("disabled", true);
$("input[type='checkbox']").prop("disabled", true);
$("input[type='checkbox']").prop("disabled", "disabled");
//设置checkbox为启用状态(jquery<1.6用attr,jquery>=1.6建议用prop)
$("input[type='checkbox']").removeAttr("disabled");
$("input[type='checkbox']").attr("disabled", false);
$("input[type='checkbox']").prop("disabled", "");
$("input[type='checkbox']").prop("disabled", false);