JS(二十七)弹框点击外部隐藏技巧

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u014744118/article/details/79465148
$(document).click(function (e) {
    if (!$(e.target).hasClass('alert-container') && $(e.target).parents('.alert-container').length === 0
        && !$(e.target).hasClass('btn-eco-bell') && $(e.target).parents('.btn-eco-bell').length === 0) {
        that.$el.find('#bellDiv').hide();
}
此事件绑定技巧在于alert-container类为弹窗div,btn-eco-bell为点击按钮,如果点击按钮或者点击弹窗内部,不隐藏弹窗,点击外部都会隐藏弹窗div

猜你喜欢

转载自blog.csdn.net/u014744118/article/details/79465148
今日推荐