checkbox全选 全不选 反选

function selectAllCheckbox(){
	var flag = $("#selectAll").attr("checked");
	if(flag){
		$("input[name=box]").attr("checked",true);
	}else{
		$("input[name=box]").attr("checked",false);
	}
}
function reverseSelect(){
	$("input[name=box]").each(function(index,obj){
	   $(this).attr("checked",!$(this).attr("checked"));
	});
}
<input type="checkbox" id="selectAll" onchange="selectAllCheckbox()"/>全选/全不选
<input type="checkbox" name="box" />
<input type="checkbox" name="box" />
<input type="checkbox" name="box" />

你可能感兴趣的:(checkbox)