jQuery disable checkbox on class

checkbox, class, jquery

Solution

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);
    }
});

Problem

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?

Original source