源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

jquery封装的对话框简单实现

  • 时间:2022-12-08 18:08 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:jquery封装的对话框简单实现
[u]复制代码[/u] 代码如下:
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 = "确认"; 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 = "错误"; 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 }); }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部