This article is a good jquery pop-up window effect code based on the jquery plug-in. For more information, see.
Function usage
$ ('Pop-Up button '). lee_dialog ({dialog: 'floating-layer object', close: 'close button '});
The Code is as follows: |
Copy code |
<! DOCTYPE html> <Html>
<Head> <Meta charset = "UTF-8"/> </Head> <Body> <Button class = "aa"> haha </button> <P> 3234234 </p> <P> 3234234 </p> <P> 3234234 </p> <P> 3234234 </p> <P> 3234 pop-up window effect code 234 </p> <P> 3234234 </p> <P> 3234234 </p> <P> 3234234 </p> <P> code 234 of the 3234jquery pop-up window effect </p> <P> 3234234 </p> <P> 323 pop-up window effect code 4234 </p>
<Div class = "dialog" style = "width: 500px; height: 200px; background: # ccc; display: none;"> <A class = "close" href = "javascript: void (0);"> close </a> </Div> </Body>
<Script type = "text/javascript" src = "jquery-1.8.2.min.js"> </script> <Script type = "text/javascript" src = "lee_plug/dialog. js"> </script> <Script type = "text/javascript"> $ ('. A'). lee_dialog ({dialog:'. dialog ', close:'. close '}); </Script>
</Html> |
Jquery code
The Code is as follows: |
Copy code |
(Function ($ ){ $. Fn. lee_dialog = function (param ){ If (typeof param. dialog = 'undefined') return; Var dialog = param. dialog; Var close = param. close | '. close '; Var speed = 400; Var margin_left = '-' + parseInt ($ (dialog). width ()/2) + 'px '; Var margin_top = '-' + parseInt ($ (dialog). height ()/2) + 'px '; Var _ this = null; Var bg = '<div class = "lee_dialog_bg" style = "width: 100%; height:' + $ (document ). height () + 'px; background: #000; opacity: 0.7; filter: alpha (opacity = 70); position: absolute; left: 0; top: 0; z-index: 2147483600; display: none; "> </div> ';
Dimensions (dialog).css ({'position': 'fixed', 'margin-left': margin_left, 'margin-top': margin_top, 'left': '000000', 'top ': '123', 'display': 'none', 'z-Index': 50% }); $ ('Body'). append (bg );
$ (This). each (function (){
_ This = $ (this );
_ This. click (function (){ If (! $ (Dialog). is (': visable ')){ $ ('. Lee_dialog_bg'). fadeIn (parseInt (speed/2 )); ((Dialog).css ({'top': '000000', 'display': 'block', 'opacity ': 35% }); $ (Dialog). animate ({top: '000000', opacity: 1}, speed ); } });
$ (Dialog + ''+ close). click (function (){ $ (Dialog ). animate ({top: '000000', opacity: 0133, speed,false,function({{}}(this}.hide().css ('top', '20170'); $ ('. lee_dialog_bg '). fadeOut (parseInt (speed/2 ));}); });
}); }
}) (JQuery ); |