原代码只能使用一次,取消选择后不能再重复选择多项
$('#chbox').click(function () {
if($('#chbox').attr('checked')){
$('.colored-blue').attr("checked","checked");
}else{
$('.colored-blue').removeAttr('checked');
}
});
修改为下面代码则实现多次选择、取消
$('#chbox').click(function () {
if($('#chbox').prop('checked')){
$('.colored-blue').prop("checked","checked");
}else{
$('.colored-blue').removeAttr('checked');
}
});