Reputation: 6471
Hello I am disabling all checkboxes which are not checked.
$(":checkbox:not(:checked)").prop('disabled', true)
My problem is that I do not know how to select only the checkboxes with the class checkbox
. I tried to do it like this:
$(".checkbox:checkbox:not(:checked)").prop('disabled', true)
Upvotes: 0
Views: 111
Reputation: 6322
See this examle http://jsfiddle.net/uwsy2xuv/1/
<input type="checkbox" class="checkbox">
<input type="checkbox">
<input type="checkbox" class="checkbox" checked>
<input type="checkbox">
<input type="checkbox">
<input type="checkbox" class="checkbox">
jquery
console.log($("input[type='checkbox']")) //selector for all checkbox.
console.log($("input[type='checkbox'].checkbox")) //selector for all checkbox which has class checkbox.
$("input[type='checkbox'].checkbox:not(:checked)").prop('disabled', true)
OR
$("input:checkbox.checkbox:not(:checked)").prop('disabled', true)
Upvotes: 2
Reputation: 167182
Use this way:
$("input.checkbox:checkbox:not(:checked)")
Upvotes: 4