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!