【问题标题】:JQuery Data Table OnClick tr td :NOT tr thJQuery 数据表 OnClick tr td :NOT tr th
【发布时间】:2019-05-22 05:02:33
【问题描述】:

我有一个 JQuery 数据表,我有一个 onClick 函数,它收集所有表行数据并显示一个模态......这很好。当我单击表格标题对行进行排序时,问题仍然存在,弹出模式因为它在表格行内......我的问题是如何允许 TR TD 工作而不是 TR TH?

我试过 :NOT selected for TH 没用

 $('#jqueryDataTable').on('click', 'tr', function () {

            //This is the selected data from the row
            selectedData = table.row(this).data();
            //Display a MODAL with this information

 });

我希望当我单击标题以对模式进行排序并且单击时不会触发。

【问题讨论】:

    标签: jquery html-table datatables onclick row


    【解决方案1】:
    //Add the event listener to the tbody tag's table rows
    //This will eliminate the problem of clicking a table header as it is contained
    //In the thead tag
     $('#jqueryDataTable tbody').on('click', 'tr', function () {
    
                //This is the selected data from the row
                selectedData = table.row(this).data();
                //Display a MODAL with this information
    
     });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-18
      • 1970-01-01
      • 2015-11-23
      • 1970-01-01
      • 1970-01-01
      • 2012-07-10
      • 1970-01-01
      • 2015-02-14
      相关资源
      最近更新 更多