I would like to enable the edit & delete flags of this line when the corresponding chkView is checked and disabled if it is not set. Firstly, this code does not work. Where am I going wrong.
http://jsfiddle.net/75rVH/1/
HTML
<table id="table_forms">
<tr>
<td><input type="checkbox" class="chkView"/>View</td>
<td><input type="checkbox" class="chkEdit" disabled/>Edit</td>
<td><input type="checkbox" class="chkDelete" disabled/>Delete</td>
</tr>
<tr>
<td><input type="checkbox" class="chkView"/>View</td>
<td><input type="checkbox" class="chkEdit" disabled/>Edit</td>
<td><input type="checkbox" class="chkDelete" disabled/>Delete</td>
</tr>
</table>
JS:
$(document).on('change','.chkView',function(){
var row = $(this).closest('tr');
if($(this).prop("checked",true))
{
$(row).find('.chkEdit').prop("disabled",false);
$(row).find('.chkDelete').prop("disabled",false);
}
else
{
$(row).find('.chkEdit').prop("disabled",true);
$(row).find('.chkDelete').prop("disabled",true);
}
});
source
share