I want to be able to retrieve all checkboxes that are disabled and add a style/background to the containing TD table cell. I can select all checkboxes and change the background as follows:
$(':checkbox').closest("td").css('background-color', '#FF0000');
I just need to update this so that it applies to only disabled items.
You can use :disabled selector:
$('input[type=checkbox]:disabled').closest("td") // .addClass('disabled');
Note that :checkbox selector has been deprecated, the alternative is attribute selector.
You can also use has method:
$('td').has('input[type=checkbox]:disabled').css('background-color', '#FF0000')
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