Reputation: 675
I have "tr" element with attribute "data-uid". How can I call that "data-uid" in my jquery for finding my checkbox to add the disabled class.
Here is my code :
<tr data-uid="994f164a-5778-49ee-b05e-abb74bbf9b93" role="row">
<td role="gridcell"><label class="row-select-wrapper">
<input type="checkbox" class="row-select"><em></em></label>
</td>
<td role="gridcell">test</td>
<td role="gridcell"></td>
<td role="gridcell"></td>
</tr>
I tried something like this
$('data-uid[994f164a-5778-49ee-b05e-abb74bbf9b93]')
.find('<input type="checkbox"').attr("disabled", "true");
Upvotes: 2
Views: 156
Reputation: 76557
You actually need to enclose the type of attribute selector that you are using in square braces as well when using attribute selectors:
$('[data-uid="994f164a-5778-49ee-b05e-abb74bbf9b93"]').find('<input type="checkbox"')
.attr("disabled", "true");
Additionally, you could simplify your selector if you wanted to target checkboxes beneath your <tr>
by using the :checkbox
pseudoselector:
// This will disable all checkboxes beneath the specified row
$('[data-uid="994f164a-5778-49ee-b05e-abb74bbf9b93"] :checkbox').prop('disabled',true);
Upvotes: 2
Reputation: 1386
You were close :
$('[data-uid=994f164a-5778-49ee-b05e-abb74bbf9b93]')
.find('input[type=checkbox]').attr("disabled", "true");
Upvotes: 2