I am trying to get data-id
value from all td
. But I only get the data-id
value from the first td
. Why am I not getting data-id
value from second td
to last td
?
This is my blade template code:
@foreach ($types as $type)
<tr>
<td>{{$type->name}}</td>
<td><a href="javascript:void(0)"
id="edit_type" data-id="{{ $type->id }}">
<i class="far fa-edit"></i></a> <a
href=""><i class="fas fa-trash-alt"></i>
</a>
</td>
</tr>
@endforeach
This is my jquery code:
$('#edit_type').click(function(){
var type_id = $(this).attr('data-id');
console.log(type_id);
});