2

My dom is simply defined as:

sDom: 't',

My datatable name is:

dataTable: "#mainTable",

and I'm trying to find all TR tags in that datatable by using this jQuery selector:

var trs = $('#mainTable').children('tr');

But for some reason when I call the below code I get "0":

alert(trs.length);

Would anyone know why?

4

1 回答 1

4

要访问表中的行,您必须使用 datatables 函数:[datatable_object].$([selector])

//Create datatable
var trs = $('#mainTable').dataTable();

//Get all rows from the trs table object.
var rows = trs.$("tr");


在http://www.datatables.net/api 的 $ 部分下有更多示例

于 2013-05-17T00:51:01.670 回答