我知道这可能看起来很原始,但我一直试图实现它一整天,也许是因为我无法完全理解如何使用API,我使用DataTables 1.10.0,我有一个分页表功能,每行都有一个复选框,我需要一个"检查所有按钮",它会检查所有页面中的所有复选框,问题是它只检查当前页面中的复选框,并且不检查其他页面,这应该很容易,但我无法理解!我发现的答案使用"fnGetNodes",似乎已被弃用,版本1.10没有使用
编辑:这是我的标记
<table class="table table-striped table-bordered table-hover" id="numbers_table">
<thead>
<tr>
<th><input type="checkbox" id="checkall" title="Select all" onClick="toggle(this)"/></th>
<th>Number</th>
<th>Company</th>
<th>Tags</th>
</tr>
</thead>
<tbody>
<% _.each(array, function (value) { %>
<tr>
<td><input type='checkbox' name='numbers[]' value='<%=value.id%>'/></td>
<td><%= value.number %></td>
<td><%= value.company %></td>
<td><%= value.tags %></td>
</tr>
<% }) %>
</tbody>
</table>
<button type="button" class="btn btn-primary" id="checkall2">SELECT ALL</button>
<script>
$(document).ready(function() {
$('#numbers_table').dataTable({
//"bPaginate": false,
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 0 ] }
]
});
$("#checkall2").click(function() { // a button with checkall2 …Run Code Online (Sandbox Code Playgroud)