【发布时间】:2021-12-23 04:37:54
【问题描述】:
在我的数据表中,我希望 jQuery 为表中的每个表行添加一个标题,所以当我将鼠标悬停在每一行上时,我会看到该行的索引。 我可以使用下面的代码捕获每个行索引,但无法将带有索引的属性“标题”作为值添加到每行
var table = $(".table").DataTable();
...
table.rows().every(function (rowIdx) {
console.log(rowIdx);
$(this).attr('title', rowIdx);//does not add a title at all
$(this).prop('title', rowIdx);//does not add a title at all
});
有什么想法吗?
感谢阅读
【问题讨论】:
-
console.log $(this) 输出什么?
-
它实际上在调试控制台中显示了行的索引号......这就是我能够捕获行的索引的意思
-
调试
this是什么 - 它不会是tr
标签: jquery datatables