<table class="table table-striped">
<thead>
<tr>
<th><input type="checkbox" id="checkAll"/></th>
<th>编号</th>
<th>姓名</th>
<th>性别</th>
<th>邮箱</th>
<th>部门编号</th>
<th>部门名称</th>
<th colspan="2">操作</th>
</tr>
</thead>
<tbody>
<c:forEach items="${pageInfo.list}" var="employee">
<tr>
<td><input type="checkbox" name="check"></td>
<td>${employee.empId}</td>
<td>${employee.empName}</td>
<td>${employee.gender}</td>
<td>${employee.email}</td>
<td>${employee.department.deptId}</td>
<td>${employee.department.deptName}</td>
<td>
<button type="button" class="btn btn-success btn-sm" href="#">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> 编辑
</button>
<button type="button" class="btn btn-danger btn-sm" href="#">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>删除
</button>
</td>
</tr>
</c:forEach>
</tbody>
</table>
一、javascript实现checkbox的全选与全不选
function selectAll() {
var node = document.getElementById("checkAll");
var nodes = document.getElementsByName("check");
if(node.checked==true){
for(var i=0;i<nodes.length;i++){
nodes[i].checked = true;
}
}else {
for(var i=0;i<nodes.length;i++){
nodes[i].checked = false;
}
}
}
二、JQuery实现checkbox的全选与全不选
$(function () {
$("#checkAll").bind("click",function () {
$('input[name="check"]').each(function () {
$(this).prop("checked",$("#checkAll").is(":checked"));
})
})
});