how to get clicked row data Jquery data table

I have jquery datatable and its grouped according to date. I want to add new event action when click group header. But I cannot get clicked group data. How to get clicked group data. I used below code, still cannot get clicked group data.

        var otable;
        otable = $('#data').DataTable({
            "sAjaxSource": "http://localhost/test/test",

    $('#data body').bind('click','',function(){
       var data = $('#data').DataTable().row(this).data()

Answers 1

  • Pass the tr element to an instance of the DataTables api. I changed your bind to on because it's the recommended way, change it back if you're using an older version.

    $('#data body').on('click','',function(){
        var data = $(your table selector).DataTable().row(this).data();

    EDIT: cleaner solution by commenter, thx

Related Articles