$('input[name="selectAll"]').click(function(){
if($(this).is(':checked')){
$('input[name="checkBox"]').each(function(){
//此处如果用attr,会出现第三次失效的情况
$(this).prop("checked",true);
});
}else{
$('input[name="checkBox"]').each(function(){
$(this).removeAttr("checked",false);
});
}
});
<td><input type="checkbox" name="selectAll"/></td>
jQuery实现checkbox点击全选和取消全选
最新推荐文章于 2023-08-18 11:12:43 发布