81,114
社区成员
发帖
与我相关
我的任务
分享$(function() {
$("#checkAll").click(function() {
$('input[name="subBox"]').attr("checked",this.checked);
});
var $subBox = $("input[name='subBox']");
$subBox.click(function(){
$("#checkAll").attr("checked",$subBox.length == $("input[name='subBox']:checked").length ? true : false);
});
}); <div title="Title1" data-options="iconCls:'icon-save'" style="overflow:auto;padding:10px;" id="div1" >
<!-- 通过js实现全选和反选功能,该checkbox的id为checkAll -->
<input type="checkbox" id="checkAll" >全选<br>
<!-- 通过标签库方式遍历数据库表名tableList,并用el表达式取得其每一个的表名称 -->
<c:forEach items="${sessionScope.tableList }" varStatus="id" var="tableName" >
<input type="checkbox" name="subBox" id="" value=${tableName }>${tableName }<br>
</c:forEach>
</div>