我正在使用 Bootstrap 表 ( http://wenzhixin.net.cn/p/bootstrap-table/docs/index.html )
我正在尝试添加点击事件
$('tr').click(function(){ console.log('test'); });
但它不起作用。我知道 bootstrap-table 库中有事件,但对我来说,将它与 jQuery 的 .click 完全结合使用很重要。你知道在 bootstrap-table 源代码中是什么阻止了这个事件吗?我尝试从 bootstrap-table.js 中删除所有“.off”,但没有帮助。
最佳答案
我认为您可以使用onClickRow
或click-row.bs.table
事件代替tr click 事件,这里是documentation和 examples .
代码示例:
// Fires when user click a row
$('#table').bootstrapTable({
onClickRow: function (row, $element) {
// row: the record corresponding to the clicked row,
// $element: the tr element.
}
});
// or
$('#table').on('click-row.bs.table', function (e, row, $element) {
// console.log(row, $element);
});
(本人是Bootstrap Table的作者,希望对您有所帮助!)
关于javascript - Bootstrap 表 - 无法在 tr 上添加点击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26567867/