jquery封裝的對(duì)話框簡單實(shí)現(xiàn)
更新時(shí)間:2013年07月21日 17:46:57 作者:
本文為大家詳細(xì)介紹下使用jquery簡單實(shí)現(xiàn)封裝的對(duì)話框,具體實(shí)現(xiàn)代碼如下,感興趣的朋友可以參考下哈,希望對(duì)大家有所幫助
復(fù)制代碼 代碼如下:
var _alert_iconCss = "tipmsg_icoInfo";
var _confirm_iconCss = "tipmsg_icoConfirm";
var _error_iconCss = "tipmsg_icoError";
var _warning_iconCss = "tipmsg_icoWarning";
function dialogInit(type, msg) {
var iconCss = "";
switch (type) {
case "confirm" : iconCss = _confirm_iconCss; break;
case "error" : iconCss = _error_iconCss; break;
case "warning" : iconCss = _warning_iconCss; break;
default : iconCss = _alert_iconCss; break;
}
var htmlStr = "<div id='" + type + "Div' style='display: none;'><p><span class='" + iconCss + "' style='float:left; margin:0 7px 50px 0;width:35px;height:35px;'></span>" + msg + "</p></div>";
return htmlStr;
}
function Alert(msg, okCallback) {
var title = "提示";
var type = "alert";
var html = dialogInit(type, msg);
var div = $("body").find("#"+type+"Div");
div.remove();
$('body').append($(html));
var buttons = {"確定" : function () {
if(okCallback) okCallback();
$(this).dialog("close");
}
};
$("#"+type+"Div").dialog({
modal : true,
title : title,
buttons : buttons
});
}
function Confirm(msg, okCallback, cancelCallback) {
var title = "確認(rèn)";
var type = "confirm";
var html = dialogInit(type, msg);
var div = $("body").find("#"+type+"Div");
div.remove();
$('body').append($(html));
var buttons = {"確定" : function () {
if(okCallback) okCallback();
$(this).dialog("close");
},
"取消" : function () {
if(cancelCallback) cancelCallback();
$(this).dialog("close");
}
};
$("#"+type+"Div").dialog({
modal : true,
title : title,
buttons : buttons
});
}
function Error(msg, okCallback) {
var title = "錯(cuò)誤";
var type = "error";
var html = dialogInit(type, msg);
var div = $("body").find("#"+type+"Div");
div.remove();
$('body').append($(html));
var buttons = {"確定" : function () {
if(okCallback) okCallback();
$(this).dialog("close");
}
};
$("#"+type+"Div").dialog({
modal : true,
title : title,
buttons : buttons
});
}
function Warning(msg, okCallback) {
var title = "警告";
var type = "warning";
var html = dialogInit(type, msg);
var div = $("body").find("#"+type+"Div");
div.remove();
$('body').append($(html));
var buttons = {"確定" : function () {
if(okCallback) okCallback();
$(this).dialog("close");
}
};
$("#"+type+"Div").dialog({
modal : true,
title : title,
buttons : buttons
});
}
相關(guān)文章
教你用jquery實(shí)現(xiàn)iframe自適應(yīng)高度
iframe因?yàn)槟芎途W(wǎng)頁無縫的結(jié)合從而不刷新頁面的情況下更新頁面的部分?jǐn)?shù)據(jù)成為可能,可是 iframe的大小卻不像層那樣可以“伸縮自如”,所以帶來了使用上的麻煩,給iframe設(shè)置高度的時(shí)候多了也不好,少了更是不行,今天我們就來分享2種使用jquery實(shí)現(xiàn)iframe自適應(yīng)高度的代碼2014-06-06
jquery實(shí)現(xiàn)最簡單的滑動(dòng)菜單效果代碼
這篇文章主要介紹了jquery實(shí)現(xiàn)最簡單的滑動(dòng)菜單效果代碼,涉及jQuery基于鼠標(biāo)事件操作頁面元素動(dòng)態(tài)變換的基本技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-09-09

