saad
saad

Reputation: 1364

uncheck all checkboxes leaving disabled one using jquery

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

Answers (3)

Kamalesh
Kamalesh

Reputation: 21

$('input[type=checkbox]').each(function () { 
     var elem = $("#" + this.id); 
     if (!elem.attr("disabled")) { 
         this.checked = true; 
     } 
 });

Upvotes: 0

Arun P Johny
Arun P Johny

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

Balachandran
Balachandran

Reputation: 9637

try

$('input[type=checkbox]').each(function(){  
      if(!$(this).prop('disabled')){
        $(this).prop("checked", false); 
      } 
})

Upvotes: 1

Related Questions