取消选中所有使用jquery保留禁用状态的复选框

saa*_*aad 0 javascript jquery

使用以下方法取消选中除禁用的复选框以外的所有复选框

$('input[type=checkbox]').each(function(){  
      if(!this.attr(':disabled')){
         this.checked = false; 
      } 
}); 
Run Code Online (Sandbox Code Playgroud)

但没有工作

Aru*_*hny 5

您可以使用:not/not()以及:disabled selector

$('input[type=checkbox]:not(:disabled)').prop('checked', false); 
//or
$('input[type=checkbox]').not(':disabled').prop('checked', false); 
Run Code Online (Sandbox Code Playgroud)