How to get the index of a row based on a button click - Datatables live link included

How to get the index of a row based on a button click - Datatables live link included

Tylerlee12Tylerlee12 Posts: 8Questions: 5Answers: 0

Hi guys,

Here's what I'm attempting to do: I have an edit button within every row. When the user clicks on that edit button, I need to get the index of that row..but I'm not sure how exactly to do that. Anyone know how to do this? Please check out my Datatables live link below to further understand my problem and make any necessary changes.

Datatables live link: http://live.datatables.net/madadak/2/edit

Thanks!

This question has an accepted answers - jump to answer

Answers

  • wjhumphreyswjhumphreys Posts: 52Questions: 9Answers: 5
    Answer ✓
    $("#example tbody").on('click', '.editButton', function() {
        alert('Row index: ' + $(this).closest('tr').index());
    });
    
This discussion has been closed.