Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable all check boxes inside a table with jquery

I need to disable all the check boxes inside a table cell when clicking on a hyperlink inside the same table.

I'm using the following jquery code to select all the check boxes nested inside the table.

$el = $(this).parents('table:eq(0)')[0].children('input[type="checkbox"]');
$($el).attr('checked', true);

For some reason this piece of code is not working.

Can anyone show me how to fix it?

like image 768
user152248 Avatar asked Sep 15 '09 10:09

user152248


People also ask

How do I unselect all checkboxes?

Clicking on the master checkbox selects all checkboxes; and unchecking it, deselects all checkboxes.

Is checkbox disabled jQuery?

In general, the checkbox disabling in jQuery is defined as disabling the checkbox element which grays out the checkbox element which can either be checked or unchecked when it is disabled by using different methods provided in jQuery such as using a prop() and attr() method and there is also one property which can be ...


1 Answers

$('table input[type=checkbox]').attr('disabled','true');

if you have an id for the table

$('table#ID input[type=checkbox]').attr('disabled','true');
like image 89
Tzury Bar Yochay Avatar answered Sep 27 '22 17:09

Tzury Bar Yochay