DataTable Image -> 当我尝试获取这样的标题名称时..那时我只有第一列名称,即 NAME ...但是我需要获取所有标头名称。如何获取所有标题名称?
this.api().columns().every( function ($i) {
var column = this;
var order = this.order();
var title = this.column(order[0][$i]).header();
var tt = $(title).html();
console.log(tt);
})
答案 0 :(得分:0)
Alert the name of the column for a cell that was clicked on:
var table = $('#example').DataTable();
$('#example tbody').on( 'click', 'td', function () {
var idx = table.cell( this ).index().column;
var title = table.column( idx ).header();
alert( 'Column title clicked on: '+$(title).html() );
} );
答案 1 :(得分:0)
似乎有点复杂:
this.api().columns().every(function() {
console.log( this.header().textContent )
})
将执行“技巧”。