I have the following code that sits within $( document ).ready(function():
$('.Spec').prop('disabled', !$('.Spec').is(':checked'));
What I am trying to do is when the page has loaded, disable any checkbox with the class Spec that are not checked.
Any reason why the above doesn't work?
To begin with, you're doing a very poorly thought-out selector mechanism for your boolean condition; how is it going to know WHICH particular checkbox within the Spec class is the one you need to evaluate?
I might suggest something more along these lines:
$('.Spec').each(function() {
if(!$(this).prop('checked')) {
$(this).prop('disabled', true);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With