(function($) { $.fn.lvmamaDialog = function(options){ var bg=null; var dialog=null; var myDiv = $(this); var options = options || {}; options.zindex=options.zindex||999; var contentDiv = $("<div style='width:100%;position:absolute'></div>") var myDivHtml = myDiv.html(); myDiv.html(""); //alert(myDivHtml); contentDiv.html(myDivHtml); //var tbFrame=$("<table width=100% border=0 height=100%><tr border=0><td style='background-color:#8fc2f1;position:absolute;width:100%;height:20px;'></td><td></td><td></td></tr></table>") var close = $("<span style='cursor:pointer;'>关闭</span>") var borderTop = $("<span style='background-color:#8fc2f1;position:absolute;width:100%;height:20px;'></span>") var borderBottom = $("<span style='background-color:#8fc2f1;position:absolute;width:100%;height:30px;margin:0 0 0 0;padding:0 0 0 0;'><table width=100% border=0 height=100% style='margin:0 0 0 0;padding:0 0 0 0;'> <tr><td align='center'><input id=confirm type='button' value='确认'/><input id=cancell type='button' value='取消'/></td></tr></table></span>"); myDiv.css("width",options.width+"px"||"800px"); myDiv.css("height",options.height+"px"||"800px"); myDiv.css("left",(($(document).width())/2-(parseInt(options.width)/2))+"px"); myDiv.css("position","absolute"); myDiv.css("background-color","white"); myDiv.css("border-style","solid"); myDiv.css("border-width","1px"); myDiv.css("border-color","#8fc2f1"); close.css("position","absolute"); close.css("width","40px"); close.css("height","20px"); close.css("padding-left",options.width-25); close.css("padding-button",options.height-20); contentDiv.css("margin-top","20px"); borderBottom.css("top",options.height-30); myDiv.append(borderTop); myDiv.append(borderBottom); myDiv.append(contentDiv); myDiv.append(close); myDiv.hide(); close.bind("click",function(){ closeDg(); }); borderBottom.find("#confirm").bind("click",function(){ options.confirm(); }); borderBottom.find("#cancell").bind("click",function(){ //alert("cancell"); closeDg(); // options.cancell(); if(typeof(options.cancell)!=undefined){ options.cancell(); } }); var closeDg = function close(){ myDiv.fadeOut(); } } $.fn.openDialog = function(){ //alert($(this).offset().top); $(this).fadeIn(); } })(jQuery);?<div id="dialog" >
</div>
?
$("#dialog").lvmamaDialog({width:400,height:200,confirm:subInfo}); $("#dialog").openDialog(); var subInfo = function(){ alert("confirm"); }?