Example code _ jquery

Source: Internet
Author: User
This article mainly introduces the sample code for jquery to implement the pop-up window effect. For more information, see JavaScript. the pop-up window is essentially a Square area in the browser and hidden at the beginning, you can only display a JavaScript event by modifying the css attribute value.

The procedure is as follows:

• Create a loading pop-up window

The Code is as follows:




JQuery instance 1: Floating window







Pop-up window


I am the title bar! X


I am a window!





• Create a css file and display it as a pop-up window

The Code is as follows:


# Win {
/* Border */
Border: 1px red solid;
/* Window height and width */
Width: 300px;
Height: 200px;
/* Window position */
Position: absolute;
Top: 100px;
Left: 350px;
/* The window is invisible at the start */
Display: none;
}
/* Control the style of the background color */
# Title {
Background-color: blue;
Color: red;
/* Control the left padding of the title bar */
Padding-left: 3px;
}
# Cotent {
Padding-left: 3px;
Padding-top: 5px;
}
/* Control the location of the close button */
# Close {
Margin-left: 188px;
/* When you move the mouse over X, the effect of a small hand appears */
Cursor: pointer;
}


• Create a JavaScript file to display the window

The Code is as follows:


Function showWin (){
/* Locate the p node and return */
Var winNode = $ ("# win ");
// Method 1: Use js to modify the css value to achieve the Display Effect
// WinNode.css ("display", "block ");
// Method 2: Use the show method of jquery to achieve the Display Effect
// WinNode. show ("slow ");
// Method 3: fade in using the fadeIn method of jquery
WinNode. fadeIn ("slow ");
}
Function hide (){
Var winNode = $ ("# win ");
// Method 1: Modify the css Value
// WinNode.css ("display", "none ");
// Method 2: fadeOut method of jquery
WinNode. fadeOut ("slow ");
// Method 3: jquery's hide Method
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.