jQuery datatables add class to tr

后端 未结 5 1862
孤独总比滥情好
孤独总比滥情好 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:41

    You would just have to use the createdRow

    $('#data-table').DataTable( {
        createdRow: function( row, data, dataIndex ) {
            // Set the data-status attribute, and add a class
            $( row ).find('td:eq(0)')
                .attr('data-status', data.status ? 'locked' : 'unlocked')
                .addClass('asset-context box');
        }
    } );
    

提交回复
热议问题