如何从 jQuery DataTable 中的所有页面获取所有复选框选中的值
尝试过不同的方式
$('.btnprimary').click(function () {
$('input[type="checkbox"]').each(function(){
if(this.checked){
alert($(this).attr('data-voucgerid'));
}
});
});
我需要在数据表分页中选中所有复选框我做错了什么
现在我只能获取一页复选框值。
您可以使用 fnGetNodes() 函数:
$('input[type=checkbox]:checked', table.fnGetNodes());
table 是你的 jquery 数据表。
我有一个使用 DataTable 版本 1.13.7 的解决方案
第一列
column(0)
是表#tabla-importar-equipamiento
中所有复选框输入的列,基于此:
let getChecked = $('#tabla-importar-equipamiento').DataTable().column(0).nodes();
getChecked = $(marcados).find('input[type="checkbox"]:checked');
console.log(getChecked);