您的位置:首页 > Web前端 > JQuery

jquery操作checkBox 一次取消选中后不能再选中

2017-12-28 08:42 573 查看
原网址 : https://www.cnblogs.com/feigao/p/7601882.html
$("input[type='checkbox']").each(function(){
$(this).attr("checked","checked");
});


$("input[type='checkbox']").each(function(){
$(this).attr("checked",true);
});


以上代码均可用实现,但存在取消选中后无效的情况

 

使用以下代码可以解决

$("input[type='checkbox']").each(function(){
this.checked=true;
});


(jquery1.9以上,checkbox attr不能重复操作)可使用prop代替

$(selector).prop("checked","checked");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: