This article has shared the specific code of the pop-up layer disappearing in any area of js clicking on it for your reference. The specific content is as follows
Use jquery (); to determine whether the click area is on the pop-up layer or on the button, otherwise the pop-up layer will disappear.
Complete code
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <pre> parent > child Match all child elements under the given parent element </pre> <div class="help"> <span class="bnt">I'm the pop-up layer</span> <ul class="foo"> <li><a href="#">Article 1</a></li> <li><a href="#">Article 2</a></li> <li><a href="#">Article 3</a></li> <li><a href="#">Article 4</a></li> </ul> </div> <style> .bnt{ width: 100px;height: 50px;background: #777;color: #fff; display: block; text-align: center; line-height: 50px; cursor: default; } .help ul{ display: none; border: 1px solid #aaa; } a{display: block;padding: 10px;} </style> <script src="../"></script> <script> (function ($) { $('.bnt').click(function(){ if($(this).hasClass('show')){ $('.help ul').hide(); $(this).removeClass('show') return ; } $('.help ul').show(); $(this).addClass('show') }) ('click',function (e) { var parent=$().parents('.foo,.help'); if(===0){ ('Not in the bullet layer and button area') //Operate this area $('.help ul').hide(); $('.bnt').removeClass('show'); }else{ ('Button and Bullet Area') } }) })(jQuery); </script> </body> </html>
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.