jQuery datatables add class to tr

后端 未结 5 1778
孤独总比滥情好
孤独总比滥情好 2021-02-01 01:55

I am using jQuery and datatables. I want to add a class to the TR element of a particular row. I know how to find the row. The console.dir(row); shows the r

5条回答
  •  走了就别回头了
    2021-02-01 02:24

    DataTable().row.add() situation:

    If you want to add class when using row add function in Datatables, you could get the TR-DOM from node() method:

    var datatable = $('#resultTable').DataTable();
    
    var trDOM = datatable.row.add( [
        "Col-1",
        "Col-2"
    ] ).draw().node();
    
    $( trDOM ).addClass('myClass');
    

提交回复
热议问题