I am using Datatable plugin in table. I am adding row dynamically by Jquery:
var t = $('#example').DataTable();
t.row.add( [
counter +'.1',
counter +'.2',
counter +'.3',
counter +'.4',
counter +'.5'
] ).draw();
Here is fiddle Demo. But i haven't found anything how can i add attributes on <tr>?
As per my need i want to add data-id,class,id and any other attributes.
This is how i solved my problem:
var data = [
counter +'.1',
counter +'.2',
counter +'.3',
counter +'.4',
counter +'.5'
];
var rowIndex = t.fnAddData(data);
var row = t.fnGetNodes(rowIndex);
$(row).attr( 'id', 'MyUniqueID' );
Working DEMO and Details
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With