仅隐藏内容,取消选中两个相应的复选框 [英] Hide the content only the two corresponding checkboxes are unchecked

查看:86
本文介绍了仅隐藏内容,取消选中两个相应的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<script type="text/javascript">
    $('#checkallindus').click(function () {
        if($('#checkallindus').attr('checked',false)){
            $('.cat1').hide();
        }
    });
    $('#checkallpro').click(function () {
        if ($('#checkallpro').attr('checked', false)) {
            $('.cat2').hide();
        }
    });
    $('.checkall').click(function () {
        if ((document.getElementById('checkallindus').checked == false) &&                                      (document.getElementById('checkallprod').checked == false)) {
            $('.disp').hide();
        }
    });
</script>







<html>
<body>
    <div class="disp">
        Case 1
        <div class="cat1">Industry: Environment</div>
        <div class="cat2">Product: ASP.NET</div>
        <div class="des">The asp.net product in the envirnmen industry</div>
    </div>
    <div class="disp">
        Case 2
        <div class="cat1">Industry: Hobbyist</div>
        <div class="cat2">Product: WinRT</div>
        <div class="des">The Winrt product in the hobbyist industry</div>
    </div>
    <div class="disp">
        <div class="cat1">Industry: Hobbysit</div>
        <div class="cat2">Product: ASP.NET</div>
        <div class="des">The ASP.NET product in the hobbyist industry</div>
    </div>
    <div class="head">Industry</div>
    <input type="checkbox" id="checkallindus" checked/>ALL
    <input type="checkbox" class="checkindus" checked/>Environment
    <input type="checkbox" class="checkindus" checked/>Hobbyist
    <div class="head">Product</div>
    <input type="checkbox" id="checkallpro" checked/>ALL
    <input type="checkbox" class="checkpro" checked/>ASP.NET
    <input type="checkbox" class="checkpro" checked/>WinRT
       </body>
       </html>





在代码中,我编写了ALL复选框的脚本,但对于不同的复选框,我无法编写脚本。只有在行业内的复选框以及产品下的相应复选框未选中时,才必须隐藏disp下的内容。在这种情况下,任何人都可以帮我写脚本吗。



In the code I have written the script for the "ALL" checkboxes but for indivual checkboxes I am unable to write the script. The content under "disp" must be hidden only if the checkbox under industry and also the corresponding checkbox under product is unchecked. Can anyone help me how to write the script in this case.

推荐答案

' #checkallindus')。点击( function (){
if
('#checkallindus').click(function () { if(


' #checkallindus') .attr(' 选中' false )){
('#checkallindus').attr('checked',false)){


' 。cat1')。hide ();
}
});
('.cat1').hide(); } });


这篇关于仅隐藏内容,取消选中两个相应的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆