var checkOne = $(".dropdown-menu li input");
var checkAll = checkOne.eq(0);
checkAll.off('click').on('click', function () {
var flag = checkAll.prop("checked");
checkOne.each(function(i){
if (i>0){
var $this = $(this);
if (flag) {
if (!$this.prop('checked')) {
$this.click();
}
} else {
if ($this.prop('checked')) {
$this.click();
}
}
}
});
});
checkOne.on('click', function () {
var len = checkOne.length;
var _l = 0;
checkOne.each(function(i){
if (i>0){
if ($(this).prop('checked')) {
_l++;
}
}
});
if (_l === len-1){
checkAll.prop("checked", true)
} else {
checkAll.prop("checked", false)
}
});
给自己填坑吧……
解决方案:
1,列参数配置上添加“全选”
2.bootstrap-table渲染
3.添加点击事件