实现动态div,实现传入函数 具体实现方法:
msg.showConfirmDialogMsg = function(msg,okCallback,cancelCallback) {
var divID=new Date().getTime().toString();
$("<div id="+divID+" >"+
"<p id=/"text/">"+msg+"</p>" +
"</div>").prependTo('body');
$("#"+divID+"").dialog({
width:400,
height: 200,
modal:true,
title:"你确定?",
autoOpen:false,
buttons:[
{
text:"OK",
handler: function() {
okCallback();
}
},
{
text:"cancel",
handler: function() {
$("#"+divID+"").dialog('close');
cancelCallback();
//alert("cancel");
}
}
]
});
};
在页面中的调用方式:
<div style="margin-bottom:10px;">
<a href="#" onclick="showConfirmDialogMsg('sssss',function() {alert('ok!');}, function() {alert('cancel!');})">open1</a>
</div>