I've tried several ways to get the row index of a clicked button inside a table.
The table:
while ($info = mysqli_fetch_array($sql)) { echo "<tr>"; echo "<th>{$info['name']}</th>"; echo "<th>{$info['pass']}</th>"; echo "<th><a href='http://{$info['link']}'>{$info['link']}</a></th>"; echo "<th><div class='delbuttons'><button class='btn btn-info' data-toggle='modal' data-target='#myModal' id='{$info['id']}'>Delete</button></div></th>"; echo "</tr>";}?>
These are the ways that I've tried:
$(document).on('click', '.delbuttons button', function(event) { alert($(this).index());}
but it always returns -1.
$(document).on('click','.delbuttons button', function(event) { alert(this.rowIndex);}
This returns undefined.