jquery 复选框全选与取消选中

$("th").on('click','#checkboxHead',function(){
var temp= $("#checkboxHead").is(':checked');
// alert(temp);
if(temp==true){
//alert("选中");
$("td input[type='checkbox']").each(function(){
// 复选框打勾
$(this).prop("checked",true);

});
}
else
{ // 复选框取消打勾
$("td input[type='checkbox']").each(function(){
$(this).removeAttr("checked");
// $(this).attr("checked",false);
});
}
});
posted @ 2017-10-09 10:17  地表热浪  阅读(238)  评论(0编辑  收藏  举报