get data row datatable jquery code example

Example 1: jquery datatables get selected row data

var table = $('#example').DataTable();
 
$('#example tbody').on( 'click', 'tr', function () {
    console.log( table.row( this ).data() );
} );

Example 2: datatable get row data

var table = $('#example').DataTable();

$('#example tbody').on( 'click', 'tr', function () {
    console.log( table.row( this ).data() );
} );

Example 3: get table row data jquery

$("document").ready(function() {
  var tb = $('.layui-table:eq(0) tbody');
  var size = tb.find("tr").length;
  console.log("Number of rows : " + size);
  tb.find("tr").each(function(index, element) {
    var colSize = $(element).find('td').length;
    console.log("  Number of cols in row " + (index + 1) + " : " + colSize);
    $(element).find('td').each(function(index, element) {
      var colVal = $(element).text();
      console.log("    Value in col " + (index + 1) + " : " + colVal.trim());
    });
  });
});

Example 4: get row data in datatable

Javascript12345var table = $('#example').DataTable(); $('#example tbody').on( 'click', 'tr', function () {    console.log( table.row( this ).data() );} );