Skip to content Skip to sidebar Skip to footer

Jquery Datatables - How To Get The Index Of A Row When A Button In That Row Is Clicked

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 exac

Solution 1:

Change the jQuery code to be this:

$(document).ready( function () {
var table = $('#example').DataTable();
    $("#example tbody").on('click', '.editButton', function() {
        alert('Row index:' + $(this).closest('tr').prevAll().length );
    });                      
} );

It starts with index 0 which I hope is what you want. I found it here if you're wondering.

Post a Comment for "Jquery Datatables - How To Get The Index Of A Row When A Button In That Row Is Clicked"