In my MVC project, Need to find selected row(tr), first child(td) data-attribute and control tagName also need to set the attribute attr('checked', 'checked');
HTML
<table class="availableProduct">
<tr>
<td>
<input type="checkbox" class="product-group" data-productid="SAP003"
data-id="Annual-46-4" data-optionid="46">
</td>
<!-- FIND THIS -->
<td>foobar</td>
</tr>
<tr>
<td>
<input type="checkbox" class="product-group" data-productid="SAP0031"
data-id="Annual-46-14" data-optionid="461">
</td>
<!-- FIND THIS -->
<td>foobar2</td>
</tr>
<tr>
<td>
<input type="checkbox" class="product-group" data-productid="SAP0032"
data-id="Annual-46-42" data-optionid="462">
</td>
<!-- FIND THIS -->
<td>foobar2</td>
</tr>
</table>
jQuery
$('table.availableProduct tr').click(function (e) {
var temp=$(this).find("td:eq(0)").html();
});
jQuery temp variable value is following
<input type="checkbox" class="product-group"
data-productid="SAP003" data-id="Annual-46-4" data-optionid="46">
On this selection want to do the following
- read all data-attribute values
- set attr('checked', 'checked');
- Need to read the tagName