您的位置:首页 > Web前端 > JavaScript

js简易漂亮的提示框

2015-07-09 17:28 585 查看
<span style="font-size:14px;">function showTips(txt, time, status) {
var htmlCon = '';
if (txt != '') {
if (status != 0 && status != undefined) {
htmlCon = '<div class="tipsBox" style="width:220px;padding:10px;background-color:#4AAF33;border-radius:4px;-webkit-border-radius: 4px;-moz-border-radius: 4px;box-shadow:0 0 3px #ddd inset;-webkit-box-shadow: 0 0 3px #ddd inset;text-align:center;position:fixed;top:25%;left:50%;z-index:999999;margin-left:-120px;"><img src="images/ok.png" style="vertical-align: middle;margin-right:5px;" alt="OK,"/>' + txt + '</div>';
} else {
htmlCon = '<div class="tipsBox" style="width:220px;padding:10px;background-color:#F75058;border-radius:4px;-webkit-border-radius: 4px;-moz-border-radius: 4px;box-shadow:0 0 3px #ddd inset;-webkit-box-shadow: 0 0 3px #ddd inset;text-align:center;position:fixed;top:25%;left:50%;z-index:999999;margin-left:-120px;"><img src="images/err.png" style="vertical-align: middle;margin-right:5px;" alt="Error,"/>' + txt + '</div>';
}
$('body').prepend(htmlCon);
if (time == '' || time == undefined) {
time = 1500;
}
setTimeout(function() {
$('.tipsBox').remove();
}, time);
}
<p>	}</span></p><p>/*</p><p>该方法可直接复制使用,
参数:text 字符串 为所提示的信息文字
time 整数 为自动消失的时间 单位为毫秒,如:1000
status 整数 1和0 为1时为正确信息提示,背景绿色,图片标示为✔符号,为0时,背景红色,标示为✘红叉
注:由于图片上传问题,大家可以自行寻找图片16*16</span>

欢迎加入Java交流群:398918539</p><p>*/</p>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: