I want to style automatic generated table rows by clicking on a button.
At the moment my code looks like this:
@foreach($tours as $tour)
<tr id="{{$tour->id}}">
<td> {{$tour->tournr}} </td>
<!-- ... -->
<button onclick="myFunction()">Click me</button>
<!-- ... -->
<script>
function myFunction() {
document.getElementById("{{$tour->id}}").style.color = "red";
}
</script>
I cut little bit out like closing tags etc.
the button in general works, but the problem is, that always just the last row gets styled.
How can I relate the button to this special row.
I thank you in advance, kirschNN