自動消失的彈窗
阿新 • • 發佈:2022-04-15
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)View Code7 .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 }
呼叫方法:
prompt(res.Message?res.Message:"自動消失的彈窗!","",1200); 效果展示: