【问题标题】:How to get the info about a row when clicking in a button in jquery datatable单击jquery数据表中的按钮时如何获取有关行的信息
【发布时间】:2017-05-16 06:41:49
【问题描述】:

我正在使用 jquery 数据表来显示数据。让我显示 id、name、pass 和控件。在 id,name,pass 数据中显示,但在每一行的控件中都有一个按钮。

我只想在单击按钮时获取行信息。我知道在整行中单击时如何获取数据或特定行。但我只想在按钮点击中获取信息。

单击行本身时,我使用以下代码显示行。

$('#example tbody').on( 'click', 'tr', function () {
      console.log( table.row( this ).data() );
  } );

【问题讨论】:

标签: jquery datatables


【解决方案1】:

由于 jquery 数据表插件的功能,您也可以获取按钮点击数据,但不能获取按钮点击数据。如果您想获取按钮点击的数据,那么您可以简单地在点击功能上编写按钮的类,而不是 tr,如下所示:

     $('#example tbody').on( 'click', '.CLASS', function () {
             console.log( table.row( this ).data() );
     } );

【讨论】:

    猜你喜欢
    • 2017-06-27
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 2017-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多