jquery to implement pop-up window effect of instance code _jquery

Source: Internet
Author: User

The JavaScript implementation pop-up window essentially draws a square area on the browser and hides it at the beginning, only to display it by modifying the CSS property values when it comes to a JavaScript event.

The approximate steps are:

• Create a div that loads a pop-up window

Copy Code code as follows:

<title>jquery Instance 1: Floating window </title>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<mce:script type= "Text/javascript" src= "Jslib/jquery.js" mce_src= "Jslib/jquery.js" ></mce:script>
<mce:script type= "Text/javascript" src= "Jslib/jquerywin.js" mce_src= "Jslib/jquerywin.js" ></mce:script >
<link type= "Text/css" rel= "stylesheet" href= "Css/win.css" mce_href= "Css/win.css" >
<body>
</body>
<a onclick= "Showwin ()" href= "#" mce_href= "#" > Pop-up </a>
<div id= "Win" >
<div id= "title" > I am the title bar! <span id= "Close" onclick= "Hide ()" >X</span></div>
<div id= "Content" > I am a window! </div>
</div>

• Create the appropriate CSS file to display as a pop-up window
Copy code code as follows:

#win {
/* Border * *
BORDER:1PX Red Solid;
/* Height and width of window * *
width:300px;
height:200px;
/* The position of the window * *
Position:absolute;
top:100px;
left:350px;
/* The window is not visible at the start * *
Display:none;
}
/* Control the background color style * *
#title {
Background-color:blue;
color:red;
/* Control the left inner margin of the title bar * *
padding-left:3px;
}
#cotent {
padding-left:3px;
padding-top:5px;
}
/* Control the position of the close button.
#close {
margin-left:188px;
* * When the mouse moved to the X, the effect of small hands * *
Cursor:pointer;
}

• Create a corresponding JavaScript file to manipulate the display of the window
Copy Code code as follows:

function Showwin () {
/* Find div node and return * *
var Winnode = $ ("#win");
Method One: Use JS to modify the value of CSS to achieve the display effect
WINNODE.CSS ("Display", "block");
Method Two: Using the Show method of jquery to realize the display effect
Winnode.show ("slow");
Method Three: Using jquery Fadein method to implement fade in
Winnode.fadein ("slow");
}
function Hide () {
var Winnode = $ ("#win");
Method One: Modify the value of the CSS
WINNODE.CSS ("Display", "none");
Method Two: The Fadeout way of jquery
Winnode.fadeout ("slow");
Method Three: The Hide method of jquery
Winnode.hide ("slow");
}

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.