Reputation: 6888
Sorry if this is obvious but have looked around and can't get this working:
row.find("td.favourite:first-child").attr('disabled', 'disabled');
I am struggling to select the checkbox inside the td at all, could anyone help me with this?
Upvotes: 1
Views: 3275
Reputation: 4348
It is suggested to use prop
instead of attr
in these cases.
Also, adding :checkbox
to your selector is equivalent to [type="checkbox"]
row.find('td.favorite:first-child input:checkbox').prop('disabled', true);
Good luck, although it will still be a better solution if you'll post your markup.
Upvotes: 3
Reputation: 311
Does your check box have an ID? If not or if it is unknown at design time, why not provide your check box with a CSS class - and then simply use the selector to select the class and disable the check box?
For example, if you give the check box a CSS Class of "MyCheckboxCSSClass" (which doesn't actually even have to be defined anywhere at all - make up a name if you like), you could then disable all check boxes with that class like so:
$(".MyCheckboxCSSClass").attr("disabled", true);
I am sure that will simplify the whole process for you.
Upvotes: 3
Reputation: 337560
Your selector is returning the first td
element, not the checkbox, try this:
row.find('td.favourite:first-child input[type="checkbox"]').attr('disabled', 'disabled');
This selector seems very verbose though. If you post up your HTML there is most likely a better way to traverse the DOM to get to the checkbox.
Upvotes: 1