gpt4 book ai didi

javascript - Jquery 从全选中排除一个复选框

转载 作者:行者123 更新时间:2023-11-30 09:40:42 25 4
gpt4 key购买 nike

我选择所有复选框的 HTML 代码

Select All <input type="checkbox"  name='select_all' id='select_all'  value='1'/>

我的 Javascript 代码选择所有复选框

<script type="text/javascript">
$('#select_all').change(function() {
var checkboxes = $(this).closest('form').find(':checkbox');
if($(this).is(':checked'))
{
checkboxes.prop('checked', true);
} else {
checkboxes.prop('checked', false);
}
});
</script>

代码运行良好并选中了所有复选框,我想从选择(全选)条件中排除以下复选框,是否可以排除以下复选框?

 <input type="checkbox"  name='sendtoparent' id='sendtoparent'  value='1'/>

最佳答案

尝试使用 not方法:

$(this).closest('form').find(':checkbox').not('#sendtoparent');

关于javascript - Jquery 从全选中排除一个复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41287843/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com