js 复选框联动,一个控制多个

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>

效果
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值