【www.bbyears.com--jquery】
函数用法介绍
$("弹层按钮").lee_dialog({dialog:"浮层对象",close:"关闭按钮"});
代码如下
3234234
3234234
3234234
3234234
3234弹窗效果代码234
3234234
3234234
3234234
3234jquery弹窗效果代码234
3234234
323弹窗效果代码4234
javascript:void(0);">关闭
<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">
$(".aa").lee_dialog({dialog:".dialog",close:".close"});
</script>
jquery代码
代码如下(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 = "";
$(dialog).css({"position":"fixed","margin-left":margin_left,"margin-top":margin_top,"left":"50%","top":"50%","display":"none","z-index":2147483601});
$("body").append(bg);
$(this).each(function(){
_this = $(this);
_this.click(function(){
if(!$(dialog).is(":visible")){
$(".lee_dialog_bg").fadeIn(parseInt(speed/2));
$(dialog).css({"top":"35%","display":"block","opacity":0.0});
$(dialog).animate({top:"50%",opacity:1},speed);
}
});
$(dialog+" "+close).click(function(){
$(dialog).animate({top:"65%",opacity:0},speed,false,function(){$(this).hide().css("top","50%");$(".lee_dialog_bg").fadeOut(parseInt(speed/2));});
});
});
}
})(jQuery);