Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to add class to only one selected row then remove it after selecting it again

$(document).ready( function () {
  var table = $('#example').DataTable();
  
  $('#example tbody').on('click', 'tr', function (event) {
    console.log('td click event');
    table.$('tr.selected').removeClass('selected');
    $(this).addClass('selected');
    
    event.stopPropagation();
});
  
  $('body').on('click', function () {
    console.log('body click event');
    table.$('tr.selected').removeClass('selected');
});
  
} );
Source by datatables.net #
 
PREVIOUS NEXT
Tagged: #add #class #selected #row #remove #selecting
ADD COMMENT
Topic
Name
1+8 =