Help me. I have problem with the code:
I have this script:
<script>
$('td input[type="checkbox"]').onclick(function () {
$(this).closest('tr').find('input[type="text"]').prop('disable', !this.checked);
}).change();
</script>
And the table:
<table class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th></th>
<th>#</th>
<th>Activity Name</th>
<th>SkillsID</th>
<th>Percentage</th>
<th><center>Time Estimate Overhead (min)</center> </th>
<th><center>Time Estimate Per Unit (min)</center></th>
<th><center>Total Time (min)</center></th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" class="others1">
<td>1</td>
<td>Preparation</td>
<td class="center">1,7,8</td>
<td class="center"></td>
<td class="center"><input type="text" id="cb1_teo_text" name="cb1_teo_text" style="width: 100%;" disabled=""></td>
<td class="center"><input type="text" id="cb1_tep_text" name="cb1_tep_text" style="width: 100%;" disabled=""></td>
<td class="center"><span id="totaTime1"/></td>
</tr>
<tr>
<td><input type="checkbox" name="others2"></td>
<td>2</td>
<td>Review of Materials</td>
<td class="center">1,7,8</td>
<td class="center"></td>
<td class="center"><input type="text" name="cb2_teo_text" style="width: 100%;" disabled=""></td>
<td class="center"><input type="text" name="cb2_tep_text" style="width: 100%;" disabled=""></td>
<td class="center"></td>
</tr>
</tbody>
</table>
I just want to enable the preceding with two when the checkbox is checked and disable when the checkbox is unchecked.