我有我的客户数据表,其中有五列。一列包含超链接。其中一列是复选框。 我想当用户点击该行时,应该选择该行(这意味着行颜色应该改变并且复选框 应该选择)。我可以用下面的代码片段来做
$("#customer").on('click', $.fn.getDataTablesClickHandler("#selectAll"));
//where customer is the html div associated with dataTable and call the same function which gets triggered
//on call of selectAll html element. Inside that function i toggle the class of row
效果很好。但我的问题是我不希望在单击其中一列内的链接时发生这种情况(即行部分)。
我该怎么做?所以基本上我如何限制在单击单元格中的特定链接时触发 getDataTablesClickHandler 或
点击单元格?
最佳答案
试试这个,你想看看哪个目标被点击了,如果是 anchor 标签就忽略它。
$("#customer").on('click', function(event) {
if(event.target.tagName == 'A')
return;
$.fn.getDataTablesClickHandler("#selectAll").apply(this);
});
关于javascript - 单击行上的行选择但不单击超链接单击 jquery 数据表中的列之一?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14000383/