Reputation: 1364
Using following approach to uncheck all checkboxes except disabled one
$('input[type=checkbox]').each(function(){
if(!this.attr(':disabled')){
this.checked = false;
}
});
but not working
Upvotes: 0
Views: 725
Reputation: 21
$('input[type=checkbox]').each(function () {
var elem = $("#" + this.id);
if (!elem.attr("disabled")) {
this.checked = true;
}
});
Upvotes: 0
Reputation: 388316
You could use :not/not() along with :disabled selector
$('input[type=checkbox]:not(:disabled)').prop('checked', false);
//or
$('input[type=checkbox]').not(':disabled').prop('checked', false);
Upvotes: 5
Reputation: 9637
try
$('input[type=checkbox]').each(function(){
if(!$(this).prop('disabled')){
$(this).prop("checked", false);
}
})
Upvotes: 1