单击checkAll时,禁止检查已禁用的复选框

use*_*779 2 checkbox jquery

下面是我用来检查所有复选框的代码.

jQuery("#checkAll").on('click',function() { // bulk checked
            var status = this.checked;
            jQuery(".selectRow").each( function() {
                jQuery(this).prop("checked",status);
            });
        });
Run Code Online (Sandbox Code Playgroud)

但是,当我点击CheckAll链接时,也会检查已禁用的复选框.单击checkAll链接时如何禁用已禁用的复选框?任何帮助将不胜感激.

Dek*_*kel 5

您可以使用:not选择器选择每个checkbox没有[disabled]属性的选择器:

$('#checkAll').on("click", function(event){
  $('input[type="checkbox"]:not([disabled])').prop('checked', true)
});
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" /><br />
<input type="checkbox" disabled="disabled" /><br />
<input type="checkbox" /><br />
<input id="checkAll" type="button" value="check all" />
Run Code Online (Sandbox Code Playgroud)