I am trying to change/disable checkbox based on the 'data-count' global attribute set in the 'td' on right of the checkbox.
data-count = 0 -> checkbox should be disabled data-count > 0 -> checkbox should be checked
$('td.day').each(function() {
// set checkbox disable
if ($(this).attr('data-count') == 0) {
}else{
// set checkbox checked
}
});
<script src="http://ift.tt/1oMJErh"></script>
<div>
<table id="mytable">
<thead>
<th> </th>
<th>Col1</th>
<th> </th>
<th>Col2</th>
</thead>
<tbody>
<tr id="rw1">
<td><input type="checkbox" name="check" /></td>
<td class="day data-count="0">10</td>
<td><input type="checkbox" name="check" /></td>
<td class="day data-count="2">11</td>
</tr>
<tr id="rw2">
<td><input type="checkbox" name="check" /></td>
<td class="day data-count="1"">20</td>
<td><input type="checkbox" name="check" /></td>
<td class="day data-count="0">21</td>
</tr>
</tbody>
</table>
</div>
Regards, Elio Fernandes
Aucun commentaire:
Enregistrer un commentaire