_contentCss_.top = -48;
_contentCss_.marginLeft = 48;
}
var _content_ = $(‘<div class=”content”></div>’).css(_contentCss_).html(opts.content).appendTo(_container_);
if (opts.buttons != null && opts.buttons.length > 0) {
_containerHeight_ -= 30;
var _buttons_ = $(‘<div class=”buttons”></div>’).appendTo(_dialog_);
$.each(opts.buttons, function (i, _button) {
$(‘<a href=”javascript:;”>’ + _button.text + ‘</a>’).click(function () {
_button.fn(me);
}).appendTo(_buttons_);
})
}
_container_.css({ height: _containerHeight_ });
this.close = function () {
me.remove();
}
this.setContent = function (content) {
_content_.html(content);
}
return this;
}
//设置默认参数
$.alert.defaults = {
title: ‘信息提示’, //对话框标题
content: null, //对话框内容
width: 200, //宽
height: 100, //高
opacity: 0.5, //透明度
icon: null, //显示在标题前面的小图标
iconBig: null, //显示在内容左侧的大图标
buttons: null, //按钮集合[{text:’按钮显示文字’,fn:回调函数(event)}],event = {}
close: true//是否显示关闭按钮
}
})(jQuery);
调用
$.alert({
title: ‘火星向你发出警告’, //对话框标题
content: ‘我们是火星人,我们就要入侵地球了,你们准备好了吗?’, //对话框内容
width: 300, //宽
height: 150, //高
opacity: 0.5, //透明度
icon: ‘icon.png’, //显示在标题前面的小图标
iconBig: ‘icon-big.png’, //显示在内容左侧的大图标
buttons: [{ text: ‘好怕怕’, fn: function () { $.alert(‘我好怕怕呀’)} }], //按钮集合[{text:’按钮显示文字’,fn:回调函数(event)}],event = {}
close: true//是否显示关闭按钮
});
七.下载
下面是我测试和使用的例子,感兴趣的朋友可以自己下载修改。
点击这里下载










