點擊圖標彈出二維碼,點擊頁面其他任何地方,彈框隱藏


我們的項目,要求點擊微信圖標,彈出二維碼,點擊其他地方,彈框隱藏,然后我就寫了下

<div class="wechart"></div>
<div class="absolute ewm whitebg" id="ewm">
                <div class="text_sao red font14">掃一掃,你會了解更多</div>
                <div><img src="Images/index/ewm.png" /></div>
            </div>  
.relative { position: relative; }
.absolute { position: absolute; }
.ewm{top:60px;left:50px;width:200px;padding:20px;box-sizing:border-box;display:none;}
    .text_sao{text-align:center;}
 //點擊微信圖標彈出二維碼
    $('.wechart').on('click', function () {
         $('.ewm').toggle();  //切換元素的可見狀態
         return false;
    })
    //點擊其他地方,二維碼隱藏
     $(document).on({"click": function(e){
                var src = e.target;
                if(src.id && src.id ==="ewm"){
                    return false;
                }else{
                    $('.ewm').hide();
                }
            }
        });

  好啦,現在就可以實現啦。

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM