如何在Datatables中获得TD的TH?现在我有一个代码可以用来在数据表上添加TD的属性:
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull) {
$('td', nRow).attr("title","PUMMM");
//takes the tds from the row and assigned title attribute
}
我想要做的是根据特定td的标题添加不同的属性。
答案 0 :(得分:1)
var columNumber = 0;
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull) {
$('td, th', nRow).each(function(){
var $this = $(this);
if($this[0].tagName == "TD"){
switch(columnNumber)
{
case 0:
$this.attr("title","Column 0");
break;
case 1:
$this.attr("title","Column 1");
break;
.
.
.
.
}
columnNumber++;
}
});
}