Write a simple and easy to use pop-up layer plugin

Source: Internet
Author: User

Nonsense not much to say, directly on the code:

First, CSS

 .overlaybackground {top:  0% 0%;    Width:  100%;    Height:  100%;    Display:none;    Position:absolute;    Background -color: #555555 -index:1001;    -moz-opacity:0.7; Opacity:.     70 =70 10%;    Left:  10%;    BORDER:16PX solid lightblue;    Background -color:white;    Z -index:1002; Overflow:auto;}  
View Code

Second, the plugin JS

(function($) {$.fn. Youngdialog=function(options) {//Default Parameters        varDefaults = {            //Title: "",Width: "80%", Height:"80%", Modal:true        }; //Overwrite by OptionsOptions =$.extend (defaults, options); //Show Block Div        if(options.) Modal) $ ("Body"). Append ("<div id= ' divbackoverlay ' class= ' overlaybackground ' ></div>"); //Content Div        varDivcontent = $ ( This); varDivoverlay = $ ("#divBackOverlay");        Divcontent.show ();        Divoverlay.show (); //StyleDivcontent.addclass ("Contentdivdialog"); Divcontent.css ("Width", Options.        Width); Divcontent.css ("Height", Options.        Height); //Close ButtonDivcontent.find ("#btnCloseDialog"). Bind ("click",function(e) {divcontent.hide ();        Divoverlay.hide ();    }); };}) (jQuery);
View Code

Third, Demo

<! DOCTYPE html>$ (document). Ready (function () {            $("#btnPopup"). Click (function () {                $("#MyDiv"). Youngdialog ({Width:"500px", Height:"400px", Modal:true                });        });    }); </script>My Content can be everything. </div> </div></body>View Code

Write a simple and easy to use pop-up layer plugin

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.