js 复选框联动,一个控制多个
<div id="hxqy_div" class="hxqy_c_div" style="background-color:#0066cc;z-index:1000;position: absolute;height: 500px; width: 520px;top:20%;left:50%;margin:1px;border:1px solid rgb(50, 36, 247);">
<div class="drag_hxqy" style="position: absolute;top:0px;left:0px;background: dodgerblue; height: 30%; width: 520px;">
<p style="position: absolute; top:0%;left:2%;">随便起个名字</p>
<p class="close_hxqy_btn" style="position: absolute; top:0%;right:2%;">X</p>
</div>
<div style="position: absolute;top:50px;left:0px;background: rgb(167, 203, 240); height: 90%; width: 520px;">
<ul>
<li style="list-style-type:none;padding: 0.1rem 0;">
<p style="display: inline;">上传dwg:</p><input id="upload_hxqy" type="file" style="position: initial;width: 50%;" accept=".dwg" multiple="multiple" /><button id="btn_upload_hxqy" style="background: #0066cc; height: 30px;width: 50px;padding:5px; border:none">上传</button>
</li>
<li style="list-style-type:none;padding: 0.1rem 0;">
<p style="display: inline;">类型选择:</p>
<p style="display: inline;"><input class="selCheck" type="checkbox" name="vehicle" value="Bike" checked="checked" />全选</p>
<form action="/example/html/form_action.asp" class="allInput" method="get" style="border:1px solid blue;margin:5px 0px 5px;">
<p style="display: inline;">A:</p>
<p style="display: inline;"><input type="checkbox" class="qyhd_hbxmhx" />1</p>
<p style="display: inline;"><input type="checkbox" class="qyhd_crxmhx" />2</p>
<p style="display: inline;"><input type="checkbox" class="qyhd_syjttd" />3/p>
</br>
<p style="display: inline;">B:</p>
<p style="display: inline;"><input type="checkbox" class="qyhd_nzyypf" />4</p>
<p style="display: inline;"><input type="checkbox" class="qyhd_dlxzypf" />5</p>
<p style="display: inline;"><input type="checkbox" class="qyhd_yhypf" />6</p>
</br>
<p style="display: inline;">C:</p>
<p style="display: inline;"><input type="checkbox" class="qyhd_chyyhb" />7</p>
<p style="display: inline;"><input type="checkbox" class="qyhd_chyycr" />8</p>
<p style="display: inline;"><input type="checkbox" class="qyhd_chjttd" />9</p>
</br>
<p style="display: inline;">D:</p>
<p style="display: inline;"><input type="checkbox" class="qyhd_cgjsyd" />10</p>
<p style="display: inline;"><input type="checkbox" class="qyhd_fcgjsyd" />11</p>
</form>
</li>
<li style="list-style-type:none;padding: 0.1rem 0;">
<p style="display: inline;">新:</p><input class="qyhd_txt_jsdw" type="text" style="margin:5px 0px 10px;width: 320px;height: 20px;" />
</li>
<li style="list-style-type:none;padding: 0.1rem 0;">
<p style="display: inline;">三:</p><input class="qyhd_txt_xmmc" type="text" style="margin:5px 0px 10px;width: 320px;height: 20px;" />
</li>
<li style="list-style-type:none;padding: 0.1rem 0;">
<p style="display: inline;">国:</p><input class="qyhd_txt_xmdz" type="text" style="margin:5px 0px 10px;width: 320px;height: 20px;" />
</li>
</ul>
<div style="text-align:center;">
<button class="qyhd_btn_qyhd" style="background: #3b3e41; height: 30px;width: 80px;margin:0px 0px 0px 5px;padding:5px; border:none">魏国</button>
<button class="qyhd_btn_scscbg" style="background: #3b3e41; height: 30px;width: 120px;margin:0px 0px 0px 5px;padding:5px; border:none">蜀国</button>
<button class="qyhd_btn_kccdbf" style="background: #3b3e41; height: 30px;width: 120px;margin:0px 0px 0px 5px;padding:5px; border:none">吴国</button>
</div>
</div>
</div>
<script>
$(".selCheck").click(function() {
var isSel = $(".selCheck").is(':checked');
console.log(isSel);
if (isSel == false) {
$("input[type='checkbox']").each(function() {
this.checked = false;
});
isSel = true;
} else {
$("input[type='checkbox']").each(function() {
this.checked = true;
});
}
});
</script>
效果