Exercises: Get the login button and the entire login panel, to add events to the Login button, click on the login layer, click the login Panel Close button, close the entire login layer

Source: Internet
Author: User

Get Login button and the entire login panel, add events to the Login button, click on the login layer, click the login Panel Close button, close the entire login layer

After clicking Sign in:

<!doctype html>
<meta charset= "UTF-8" >
<title>Document</title>
<style>
*{margin:0;padding:0;}
. head{font-size:12px;padding:6px 0 0 10px;}
#login_box {width:300px;height:150px;background: #eee;
border:1px solid #ccc;p Osition:absolute;left:50%;top:50%;margin-left:-150px;margin-top:-75px;display:none;}
#login_box p{height:20px;border-bottom:1px solid #ccc; font-size:12px;padding:6px 0 0 5px;font-weight:bold;}
#close {width:14px;height:14px;background:url (close.png) no-repeat;position:absolute;right:4px;top:6px;}
</style>
<script>
Window.onload=function () {
var Login_btn=document.getelementbyid (' login '),
Login_box=document.getelementbyid (' Login_box '),
Close=document.getelementbyid (' close ');
//Package Add Event listener
function Addevent (ele,type,hander) {
if (ele.addeventlistener) {
Ele.addeventlistener (type,hander,false);
}else if (ele.attachevent) {
ele.attachevent (' on ' +type,hander);
}else{
ele[' on ' +type]=hander;
}
}
Show Login Layer Functions
function Showlogin () {
login_box.style.display= ' block ';
}
Hide Login Layer Functions
function Hidelogin () {
Login_box.style.display= ' None ';
}
//Click the login button to display the login layer
addevent (login_btn, ' click ', Showlogin);
//Click the Close button to hide the login layer
addevent (Close, ' click ', Hidelogin);
}
</script>
<body>
<div class= "Head" > Pro, Hello! <input type= "button" value= "Login" id= "Login" ></div>
<div id= "Login_box" >
<p> User Login </p><span id= "Close" ></span>
</div>
</body>

Exercises: Get the login button and the entire login panel, to add events to the Login button, click on the login layer, click the login Panel Close button, close the entire login layer

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.