【问题标题】:using datatables to the data attribute对数据属性使用数据表
【发布时间】:2021-01-15 00:41:19
【问题描述】:

以下是我尝试查找发生在服务器端的数据包的数据属性,但我没有得到它

$('#mytable tbody').on('dblclick', 'tr', function () {
        var data = table.row(this).find('data-source');
        console.log(data);
        console.log(data.find('data-source'));
  });

这块在控制台的html看起来是这样的

https://prnt.sc/wntp08

我正在尝试获取价值,但我使用的代码不正确

【问题讨论】:

  • 你的数据表的结构是什么?
  • table 未定义。在我看来,这就像检查员,而不是控制台。 .find('[data-source]') 是通过 HTML 属性获取元素的方式。

标签: javascript jquery datatable datatables


【解决方案1】:

这是您的代码的解决方案

方法一:

您可以通过 class 下拉菜单使用

 console.log($(this).find('.dropdown').data('source'));

方法二:

你可以用元素 div

 console.log($(this).find('div').data('source'));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-20
    • 1970-01-01
    • 1970-01-01
    • 2022-11-25
    • 2015-01-23
    • 2011-06-04
    • 2021-11-03
    相关资源
    最近更新 更多