user3408779 user3408779 - 1 month ago 17
jQuery Question

prevent already disabled checkbox from being checked when click on checkAll

Below is the code i am using for check all the check boxes.

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


But already disabled checkbox is also checked when i click on CheckAll link. How to stop already disabled checkbox from being checked when click on checkAll link? Any help would be greatly appreciated.

Answer

You are almost there. Use the not(":disabled") filter with your current code and it will leave out those checkboxes which are disabled.

jQuery(".selectRow").not(":disabled")...

See this question which looks very similar: jquery selector for all checked checkboxes that are not disabled