zoukankan      html  css  js  c++  java
  • js实现点击空白处隐藏

    部分业务要求除了某元素外点击其他对象,对应的元素隐藏,下面是一个demo效果,

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>demo</title>
    
        <style type="text/css">
            .fun-set-bg{100%;height:100%;overflow-x:hidden;overflow-y:auto;}
            .maskTask{ 100%;position: fixed;opacity: .5;left: 0;top: 0;height: 100%;z-index: 1;background-color: #000;display: none;}
            .maskCone{ 70%;position: fixed;background-color: #fff;z-index: 2;height: 30%;left: 15%;top: 5%;border-radius: 5px;padding: 10px 20px;display: none;}
            #btns{padding: 2px 8px;border-radius: 3px;}
    
        </style>
    </head>
    <body>
    <div class="fun-set-bg">
        demo样式-
        <button class="starts">出现</button>
    </div>
    <div class="maskTask"></div>
    <div class="maskCone">
        <p>阿部察察错错</p>
        <button id="btns">取消</button>
    </div>
    <script type="text/javascript" src="../../js/jquery_v3.3.1.js"></script>
    
    <script>
    $(function(){
        $(".starts").click(function(event){
            var e=window.event || event;
            if(e.stopPropagation){
                e.stopPropagation();
            }else{
                e.cancelBubble = true;
            }   
            $(".maskCone,.maskTask").show();
        });
        $(".maskCone").click(function(event){
            var e=window.event || event;
            if(e.stopPropagation){
                e.stopPropagation();
            }else{
                e.cancelBubble = true;
            }
        });
        $(document).click(function(event) {
            $(".maskCone,.maskTask").hide();
        });
       $('#btns').click(function(event) {
            $(".maskCone,.maskTask").hide();
        });
    })
    </script>
    </body>
    </html>
  • 相关阅读:
    PAT顶级 1024 Currency Exchange Centers (35分)(最小生成树)
    Codeforces 1282B2 K for the Price of One (Hard Version)
    1023 Have Fun with Numbers (20)
    1005 Spell It Right (20)
    1092 To Buy or Not to Buy (20)
    1118 Birds in Forest (25)
    1130 Infix Expression (25)
    1085 Perfect Sequence (25)
    1109 Group Photo (25)
    1073 Scientific Notation (20)
  • 原文地址:https://www.cnblogs.com/lvxisha/p/10826293.html
Copyright © 2011-2022 走看看