自动消失的弹窗

 1 function prompt(message, style, time){
 2             style = (style === undefined) ? 'alert-success' : style;
 3             time = (time === undefined) ? 1200 : time;
 4             $('<div id="promptModal">')
 5                 .appendTo('body')
 6                 //.addClass('alert '+ style)
 7                 .css({"display":"block",
 8                     "z-index":99999,
 9                     "left":($(document.body).outerWidth(true) - 120) / 2,
10                     "top":($(window).height() - 45) / 2,
11                     "position": "absolute",
12                     "padding": "20px",
13                     "border": "1px solid #2D8CF0",
14                     "border-radius": "5px"})
15                 .html(message)
16                 .show()
17                 .delay(time)
18                 .fadeOut(10,function(){
19                     $('#promptModal').remove();
20                 });
21         }
View Code

调用方法:

prompt(res.Message?res.Message:"自动消失的弹窗!","",1200);
 
效果展示:
posted @ 2022-04-15 18:27  Redamancy_TT  阅读(186)  评论(0)    收藏  举报