Blog · 07/01/2021

How to get the clicked row index in a jQuery table

If you are trying to get the index of the row that a table has been clicked easily, I invite you to do so using jQuery in the following way:

$("#indexedTable").delegate("tr", "click", function(e) {
    console.log($(e.currentTarget).index() + 1);
});

This code returns the index on our table, with which you will then be able to do the necessary operations, such as deleting a record.



I hope I have helped you, would you know how to do it also using JavaScript only?