Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get all disabled checkboxes

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.

like image 365
KDee Avatar asked Feb 02 '26 08:02

KDee


1 Answers

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')
like image 183
undefined Avatar answered Feb 03 '26 23:02

undefined



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!