When I click on a row in my datatable, I want the selected row to have a background color of red and all other rows to have a background color of white.
I attempted to achieve this with the following code:
$(document).on('click', "#table_user tr:not(:first) td:first-child", function() {
var row_num = parseInt( $(this).parent().index() )+1;
if(row_num == $(this).closest('tr').index()+1){
$(this).css({'background-color':'red'});
}else{
$(this).css({'background-color':'white'});
}
});
Unfortunately, this code does not seem to work as expected.