为了账号安全,请及时绑定邮箱和手机立即绑定

在 JS 的 DataTable 中打断 table.rows().iterator()

在 JS 的 DataTable 中打断 table.rows().iterator()

慕斯709654 2023-06-09 15:19:16
我想中断 DataTable() 交互。这是我的代码            let allCheckboxChecked=true;            let table = $('#myTable').DataTable();                       table.rows().iterator( 'row', function ( context, index ) {                if($(this.row(index).node()).find("input").is(":Checked")){                    allCheckboxChecked=true;                }                else{                    allCheckboxChecked=false;                    **return true;**    // This is not working...I want your help here                }            } );
查看完整描述

1 回答

?
喵喔喔

TA贡献1735条经验 获得超5个赞

使用nodes()而不是iterator()


table.rows().nodes().to$().find('input:not(:checked):first').length // 0 - all checked

或与each()


let allCheckboxChecked = true;

table.rows().nodes().to$().each(function () {

    if (!$(this).find('input').is(':checked')) {

        allCheckboxChecked = false;

        return false;

    }

})


查看完整回答
反对 回复 2023-06-09
  • 1 回答
  • 0 关注
  • 98 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信