JQuery数据表将类添加到initComplete中的第一行

JQuery数据表将类添加到initComplete中的第一行,jquery,datatables,Jquery,Datatables,我正在使用 我想选择表的第一行,并将“DTTT_selected”类添加到第一行 我已经成功地选择了第一行,但是当我添加类时,它会将“DTTT_selected”添加到所有行,而不是第一个选择的行 代码是:- table = $('#resultTable').DataTable({ aaSorting: [], ajax: {...}, columnDefs: [...], initComplete: function () { console.log('DataTables has

我正在使用 我想选择表的第一行,并将“DTTT_selected”类添加到第一行

我已经成功地选择了第一行,但是当我添加类时,它会将“DTTT_selected”添加到所有行,而不是第一个选择的行

代码是:-

table = $('#resultTable').DataTable({
aaSorting: [],
ajax: {...},
columnDefs: [...],
initComplete: function () {
    console.log('DataTables has finished its initialisation.');
    var api = this.api();
    var CurrentRow = api.row({ order: 'current' }, 0);
    CurrentRow.select(); //Working Fine
    CurrentRow.$('tr').addClass('DTTT_selected'); // Results all Rows get class DTTT_selected
    }
  }
});
有人能帮我吗?我该怎么做

谢谢。

试试看

CurrentRow.$('tr:first').addClass('DTTT_selected');
试一试

尝试当前行。$('tr:eq(0)').addClass('DTTT_selected');尝试当前行。$('tr:eq(0)').addClass('DTTT_selected');