获取数据表单元格的元素

Getting the element of a cell of datatable

我正在使用来自该站点的数据表: https://datatables.net/examples/api/select_single_row.html

我想从选定行的特定单元格(第一个)获取数据。 这可能吗?

 table.row('.selected').remove().draw(false);

我可以获取选定的行并将其删除(网站上有描述)但我不知道如何获取单元格的值。

如果您有任何建议,我将不胜感激。

您可能正在寻找

table.row('.selected').data()

你可以这样做

var d = table.row('.selected').data();

然后引用带有

的任何列
alert(d.MyColumnName);  // Returns the value of the selected row & column.

假设您使用的是 DataTables 1.10 或更高版本。

访问 selected 行,然后是数据,我们想要第一个 属性 所以我们 select 第一个索引(即 0)

(Demo)

$('#button').click( function () {
    alert(table.row('.selected').data()[0]);
});