我的dom简单定义为:
sDom: 't',
我的数据表名称是:
dataTable: "#mainTable",
我正在尝试使用此 jQuery 选择器在该数据表中查找所有 TR 标记:
var trs = $('#mainTable').children('tr');
但出于某种原因,当我调用下面的代码时,我得到“0”:
alert(trs.length);
谁知道为什么?
最佳答案
要访问表中的行,您必须使用数据表函数:[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 上的 $ 部分下有更多示例
关于javascript - 我无法在数据表中找到所有 TR 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16599055/