<body>
<div align="center">
<div id="check">
<input type="checkbox" value="1">吸烟
<input type="checkbox" value="2">喝酒
<input type="checkbox" value="3">烫头
<input type="checkbox" value="4">逗鸟
<input type="checkbox" value="5">散步
<input type="checkbox" value="6">打太极
</div>
<br>
<input type="checkbox" id="all">全选
<input type="checkbox" id="fanxuan">反选
</div>
</body>
<script type="text/javascript">
$('#fanxuan').change(function(){
if($(this).is(':checked')){
$('#check').children(':checkbox').each(function(){
$(this).prop('checked',$(this).is(':checked')?false:true);
});
}
});
</script>
<script type="text/javascript" src="jquery-3.2.1.js"></script>//**改成你自己的jquery文件路径**
<script type="text/javascript">
$('#all').change(function(){
$('#check').children(':checkbox').prop('checked',$(this).is(':checked')?true:false);
});
</script>
checkbox全选反选ctrl + c 无脑式解决
最新推荐文章于 2022-08-13 22:42:44 发布