【www.gdgbn.com--jquery】

$.fn.hdialog = function (options) {
var defaults = {
width: 300,
height: 200,
title: "此处标题",
html: "",
iconcls: "",
submit: function () { alert("可执行代码."); }
}
var id = $(this).attr("id");
options = $.extend(defaults, options);
var self = this;

$(self).dialog({
title: options.title,
height: options.height,
width: options.width,
iconcls: options.iconcls,
buttons: [{
text: "确定",
iconcls: "icon-ok",
handler: options.submit
}, {
text: "取消",
iconcls: "icon-cancel",
handler: function () {
$("#" + id).dialog("close");
}
}]
});

function createcontent() {
$(".dialog-content",$(self)).empty().append("");
$("#" + id + "_content").html(options.html);
}
createcontent();
}

调用方法

 

$(function(){
  var d =$("");
  $("#d").hdialog({submit:function(){$(d).dialog("close");}});
})

本文来源:http://www.gdgbn.com/wangyezhizuo/27955/