[英]Adding tooltip to specific datatable column
I am trying to find a way in adding the tooltip only when my mouse hovers over the card_name column. 我试图找到一种仅在鼠标悬停在card_name列上时添加工具提示的方法。 I managed to add my tooltips into datatables and this tool tip basically is an image tool tip, but it is added to the entire row instead. 我设法将工具提示添加到数据表中,并且该工具提示基本上是图像工具提示,但实际上它被添加到整个行中。
$(document).ready(function() {
var otable = $('#example').dataTable( {
"bProcessing": true,
"bServerSide": false,
"sAjaxSource": "getTrackerData.php",
"aoColumns": [
{ "mDataProp": "card_name", },
{ "mDataProp": "card_id"},
{ "mDataProp": "card_series_id" },
{ "mDataProp": "card_type_track" },
{ "mDataProp": "track_url" },
{ "mDataProp": "track_status" },
{ "mDataProp": "card_img_url" }
],
"fnDrawCallback": function(settings){
$('#example tbody tr').each(function () {
//var $td = $(this);
//$td.attr('title', $td.text());
var nTds = $('td', this);
var sURL = $(nTds[6]).text();
var t = "<img src='"+sURL+"' width='90' height='126'>"
nTds.attr('title', t);
});
/* Apply the tooltips */
$('#example tr').tooltip({
"delay": 0,
"track": true,
"fade": 250,
content: function (){
return $(this).prop('title');
}
}); // end for tooltip
}// end for fnDrawCallback
} ); // end of datatable
} );
Because you used it to match a ROW: 因为您使用它来匹配ROW:
$('#example tr').tooltip({
Just change to match COLs and use a simplified code: 只需更改以匹配COL并使用简化的代码即可:
$('#example td[title]').tooltip();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.