How to add attribute in TR and TD?

Use createdRow and columns.createdCell options to define a callback function that will be called when TR and TD element are created.

$('#example').dataTable( {
  'createdRow': function( row, data, dataIndex ) {
      $(row).attr('id', 'someID');
  },
  'columnDefs': [
     {
        'targets': 3,
        'createdCell':  function (td, cellData, rowData, row, col) {
           $(td).attr('id', 'otherID'); 
        }
     }
  ]
});

See this example for code and demonstration.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)