I have this interface, when I clicked the checkbox, the input will open
I use JQuery for this function and the problem is, only first row is able to open when checked the checkbox. Below are my code:
html:
<div class="row">
<div class="col">
<table class="table table-bordered table-hover">
<tr>
<th >Name</th>
<th >Age</th>
</tr>
@foreach($peoples as $people)
<tr>
<td >
<input type="checkbox" id="name" name="name" value=""/>
{{$people->name}}
</td>
<td>
<input type="number" id="age" name="age" value="{{$people->age}}" disabled />
</td>
</tr>
@endforeach
</table>
</div>
</div>
JQuery
<script>
$(document).ready(function () {
$('#name').on('change', function () {
$("#age").prop("disabled", !$(this).is(':checked'));
$("#age").val('');
});
});
</script>

$("#age")will only reference the first one