bootstrap 样式代码
<div class="md-checkbox has-success">
<input type="checkbox" id="rlt-chk-all-checkboxBox-work" class="md-check" name="ult-chk-all-work">
<label for="rlt-chk-all-checkboxBox-work">
<span class="inc"></span>
<span class="check"></span>
<span class="box"></span>
</label>
</div>
//table tbody中
<c:forEach items="${projectList }" var="item" varStatus="li">
<div class="md-checkbox has-success">
<input type="checkbox" id="rlt-chk-checkbox${li.count }" class='ult-chk' name='rlt-chk-work' value=" ${item.ID }">
<label for="rlt-chk-checkbox${li.count }">
<span class="inc"></span>
<span class="check"></span>
<span class="box"></span>
</label>
</div>
</c:forEach>
//全选按钮功能
$('[name=ult-chk-all-work]').on('change', function(){
$('[name=rlt-chk-work]').prop('checked', $('[name=ult-chk-all-work]').prop('checked'));
});
//按钮执行js逻辑
$("#button").click(function(){
var workIds = [];
$('[name=rlt-chk-role]:checked').each(function(index, item){
workIds.push(item.getAttribute('value'));
});
$.post("url",{data:workIds.toString()},function(data){
逻辑处理
})
<!--执行的业务逻辑 把value toString在传入后台 workIds.toString(),然后后台直接split 分割取值就行
eg: String workIdsString = request.getParameter("workIds");
String[] roleIds = String.split(",");
})