gpt4 book ai didi

jquery - 如何显示每个单元格的工具提示?

转载 作者:行者123 更新时间:2023-12-03 22:58:50 25 4
gpt4 key购买 nike

如何修改代码以将每个单元格信息显示到工具提示中?

http://datatables.net/release-datatables/examples/advanced_init/events_post_init.html

$(document).ready(function() {
/*
* First step is to create title attributes for the rows in the table
* This isn't needed if the required 'title' attribute is already set in the HTML in the
* DOM
*/
$('#example tbody tr').each( function() {
var sTitle;
var nTds = $('td', this);
var sBrowser = $(nTds[1]).text();
var sGrade = $(nTds[4]).text();

if ( sGrade == "A" )
sTitle = sBrowser+' will provide a first class (A) level of CSS support.';
else if ( sGrade == "C" )
sTitle = sBrowser+' will provide a core (C) level of CSS support.';
else if ( sGrade == "X" )
sTitle = sBrowser+' does not provide CSS support or has a broken implementation. Block CSS.';
else
sTitle = sBrowser+' will provide an undefined level of CSS support.';

this.setAttribute( 'title', sTitle );
} );

/* Init DataTables */
var oTable = $('#example').dataTable();

/* Apply the tooltips */
oTable.$('tr').tooltip( {
"delay": 0,
"track": true,
"fade": 250
} );
} );

最佳答案

你可以做到

{ "sTitle": "...", ...
'fnCreatedCell': function(nTd, sData, oData, iRow, iCol) {
nTd.title = 'Some more information';
}
}

在您的列配置中。您可以像这样轻松地使用所有行数据。当然,这个一定不能缺少:

oTable.$('td').tooltip( {
"delay": 0,
"track": true,
"fade": 100
} );

关于jquery - 如何显示每个单元格的工具提示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11309749/

25 4 0
文章推荐: JQuery UI 弹跳效果 - 输入 div 时仅弹跳一次
文章推荐: jQuery wrapAll 的行为不符合预期
文章推荐: jQuery.on() - 如何在元素加载后立即初始化
文章推荐: jquery - 从 Chrome 扩展内容脚本中选择