How can I select all checkboxes from all the pages in a jQuery DataTable

前端 未结 6 2059
既然无缘
既然无缘 2020-11-29 05:11

I have HTML page which have multiple checkboxes and individually they can be checked. I have button for \"Select All\" and when I click on this button all the check

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 06:02

    Use datatable $ instance for selections https://datatables.net/docs/DataTables/1.9.4/#$

    $(document).ready(function () { 
        var oTable = $('#example').dataTable({
            stateSave: true
        });
    
        $("#selectAll").on("change", function(){
            oTable.$("input[type='checkbox']").attr('checked', $(this.checked));  
        });
    });
    

提交回复
热议问题