首页 > 其他 > 详细

点击页面其他地方隐藏弹窗

时间:2017-05-31 18:10:23      阅读:274      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script src="js/jquery-2.1.3.min.js"></script>
        <style>
            .tip{
                margin:300px auto;
                width:200px;
                height:100px;
                text-align: center;
                background:green;
                color:#fff;
                display:none;
            }
        </style>
    </head>
    <body>
        <button>点我</button>
            <div class="tip">
                这里是提示信息!提示信息!提示信息!
            </div>
        <script>
            $(function(){
                $(button).click(function(e){
                    $(.tip).show();
                    
                    e.stopPropagation();
                    $(document).one(click,function(){
                        $(.tip).hide();
                    })
                })
                
                $(.tip).click(function(e){
                    e.stopPropagation();
                })
            })
        </script>
    </body>
</html>

 

one() 方法为被选元素附加一个或多个事件处理程序,并规定当事件发生时运行的函数。

当使用 one() 方法时,每个元素只能运行一次事件处理器函数。

点击页面其他地方隐藏弹窗

原文:http://www.cnblogs.com/wj19940520/p/6925208.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!