[英]row selection on row click but not on hyperlink click in one of the column in jquery datatable?
我有我的客户dataTable有五列。 一列包含超链接。 其中一列是复选框。 我想当用户点击该行时,应该选择该行(这意味着应该更改行颜色并选择复选框)。 我可以使用下面的代码片段来完成它
$("#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或
点击单元格?
试试这个,你想看看哪个目标被点击了,如果它是一个锚标记就忽略它。
$("#customer").on('click', function(event) {
if(event.target.tagName == 'A')
return;
$.fn.getDataTablesClickHandler("#selectAll").apply(this);
});
你可以这样做:
如果顾客是你的餐桌;
$("#customer").on('click', 'tr', function(){
if( !$(this).is('tr') )
return;
$.fn.getDataTablesClickHandler("#selectAll");
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.