Home  >  Article  >  Web Front-end  >  JS pop-up box clicks outside to hide the trick code

JS pop-up box clicks outside to hide the trick code

小云云
小云云Original
2018-03-07 15:14:562083browse

This article mainly shares with you the JS pop-up box click external hidden skill code, I hope it can help everyone.

$(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('#bellp').hide();
}

The trick of this event binding is that the alert-container class is a pop-up window p, and btn-eco-bell is a click button. If you click the button or click inside the pop-up window, the pop-up window will not be hidden. Clicking outside will hide the pop-up window. Window p

Related recommendations:

JS custom pop-up box plug-in encapsulation example introduction

javascript example of implementing a pop-up box that cannot be closed Code

jQuery click anywhere to hide DIV function

The above is the detailed content of JS pop-up box clicks outside to hide the trick code. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn