I am trying to set a css class to a row using the DataTables, query plugin for tables.
I managed to set the class on the tr tag when the initialization was complete with:
"fnInitComplete": function(oSettings) {
for (var i = 0, iLen = oSettings.aoData.length; i < iLen; i++) {
oSettings.aoData[i].nTr.className = "myClass";
}
},
I want to set a callback for each new row, and set to tr class a and to td class b
I know how to add a class, and i need to set a class!
"fnRowCallback": function(nRow, aaData, iDisplayIndex) {
console.log(aaData);
$('tr', nRow).addClass('a');
$('td:eq(0)', nRow).addClass('b');
$('td:eq(1)', nRow).addClass('b');
$('td:eq(2)', nRow).addClass('b');
$('td:eq(3)', nRow).addClass('b');
return nRow;
},
this is what troubles me:
$('tr', nRow).addClass('a');
I don't know how to set a class to a tr tag.