JQuery clicks outside of itself to close a simple instance of the pop up layer

  • 2020-03-30 01:01:42
  • OfStack

The main function is to click the display, and then by clicking anywhere on the page can turn off the display effect, mainly $(document).click

During the development process, there are often some pop-up layers, which will be automatically closed when you click on other places on the page. The following is the implementation code:

HTML code:

<div class="down">click</div>
<div class="con hide">show-area</div>

The CSS code:
. Hide {display: none; }

JS code


OK, oneself local test next, CSS style oneself modify!

Related articles: