我的dom简单定义为:
sDom: 't',
我的数据表名称是:
dataTable: "#mainTable",
我试图通过使用这个jQuery选择器找到该数据表中的所有TR标记:
var trs = $('#mainTable').children('tr');
但由于某种原因,当我调用下面的代码时,我得到“0”:
alert(trs.length);
有人知道为什么吗?
答案 0 :(得分:4)
要访问表中的行,必须使用datatables函数:[datatable_object].$([selector])
//Create datatable
var trs = $('#mainTable').dataTable();
//Get all rows from the trs table object.
var rows = trs.$("tr");
上的$部分下有更多示例