我正在使用datatable 1.9和tabletool.js 2.1.5。我总共有23条记录,每页10条记录。我想选择当前显示的页面记录。
我已经使用了TableTools.js按钮(select_all)。但这会选择数据表的所有行。我试过了
$('#file-records> tbody > tr').each(function() {
TableTools.fnGetInstance('file-records').fnSelect($(this));
});
上面的代码给了我一个错误Uncaught TypeError:无法读取未定义的属性'nTr'
我已经实现了以下
$('#file-records> tbody > tr').each(function() {
$(this).addClass("active");
});
$(this).addClass(“ active”); 添加一个背景颜色:#017ebc我已经在css文件中编写了。
因此,当您想获取选定的行值时,可以使用
$('#file-records> tbody > tr').each(function() {
if($(this).hasClass('active')){
console.log($(this)[0]);
}
});
$(this)[0]是我的行属性,从中我们可以获取实际的行内容
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句