After the expression layer pops up based on jquery, click outside the area layer disappears

Source: Internet
Author: User
The code is as follows Copy Code
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title> expression layer pops up, click outside the area layer disappears </title>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<meta name= "description" content= ""/>
<meta name= "keywords" content= ""/>
<meta name= "Robots" content= "Index,follow"/>
<link rel= "stylesheet" type= "Text/css" href= "Reset.css"/>
<style type= "Text/css" >
body{Text-align:center;}
. container{margin:0 Auto;
. popup{Background-color: #33CC99; display:none; width:200px; height:200px;/*position:absolute; left:400px; top:100 px;*/border:5px solid #FF9999; border-radius:5px; margin:0 Auto; margin-top:100px; }
. Popup ul li{line-height:1.5em;
</style>
<script type= "Text/javascript" src= "Jquery-1.7.min.js" ></script>
<script type= "Text/javascript" >

</script>
<body>
<div class= "Container" >
<p><button id= "Btnpop" type= "button" onclick= "return ShowPopup ();" > Popup div Layer </button></p>
<div id= "Popup" class= "Popup" >
<ul>
<li><span>css</span></li>
<li><span>html</span></li>
<li><span>js</span></li>
<li><span>csharp</span></li>
<li><span>sql</span></li>
</ul>
</div>
</div>
</body>
<script type= "Text/javascript" >
function ShowPopup () {
document.getElementById ("Popup"). Style.display = "block";
}
function Hidepopup () {
document.getElementById ("Popup"). Style.display = "None";
}
document.getElementById ("popup"). onclick = function (e) {
E = e | | window.event;
if (window.event) {
E.cancelbubble = true;
} else {
E.stoppropagation ();
}
};
Document.body.onclick = function (e) {
E = e | | window.event;
var target = E.target | | E.srcelement;
if (target.id = = = "Btnpop") return;
Hidepopup ();
};
</script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.