【发布时间】:2023-03-16 23:24:02
【问题描述】:
选中任何复选框后,我已经能够显示/隐藏 div。我还能够创建一个选中所有复选框的检查所有按钮。现在的问题是如何将两者联系在一起?
当我点击全部检查时,它不会显示/隐藏我想要显示/隐藏的 div,但是当您单独选择每个 div 时它会起作用。 Here is the page url
奖励:如果有人也能做到,那么“全选”按钮变为“取消全选”谢谢社区!
脚本:
<script>
$('input[type=checkbox]').change(
function(){
if($('input[type=checkbox]').is(':checked')){
// if any of the checkboxes are checked then make the area visible
$('.send-control').fadeIn();
}else{
// only if all are unchecked will this fire and hide the area
$('.send-control').fadeOut();
}
});
$('#toggle-all').click(function() {
$('input[type="checkbox"]').prop('checked',true);
});
</script>
【问题讨论】:
标签: twitter-bootstrap checkbox