【发布时间】:2015-07-08 04:25:04
【问题描述】:
脚本:
$(document).ready(function() {
$(function(){
$("#result").dataTable({
"scrollX" : true,
"ordering" : true,
"order": [[ 1, "asc" ]],
"info" : true,
});
});
$("#all").click(function () {
if ($("#all").is(':checked')) {
$(".checkboxclass").each(function () {
$(this).prop("checked", true);
});
} else {
$(".checkboxclass").each(function () {
$(this).prop("checked", false);
});
}
});
});
HTML:
<table class="tg" id="result" style="width: 100%">
<thead>
<tr>
<th class="tg" style="text-align: center"><input type="checkbox" id="all"
onclick="toggle(this);" /></th>
</tr>
</thead>
<tbody>
<tr th:each="map : ${listID}">
<td class="tg bg" align="center"><input type="checkbox" class="checkboxclass" name="check"
th:id="${map['ID']}" th:value="${map['ID']}" /></td>
</tr>
</tbody>
</table>
选中一个复选框会选择所有但仅限于当前页面。它不适用于分页中的其余页面
任何人都可以帮助解决这个问题。谢谢。
【问题讨论】:
-
您的意思是它适用于首页但不适用于其他页面?并且您希望它适用于分页中的每一页或所有记录?
-
它适用于第一页。我想让它适用于所有页面(表中的所有记录)
-
每一页和所有记录都不一样?
-
为什么
$(document).ready(function() {和$(function(){都在里面?对我来说似乎相当不必要。
标签: javascript jquery html checkbox datatable