jQuery pop-up message disappears concise edition

// In your bootstrap can be used as way to achieve pop-up message automatically disappears if no bootstrap framework, you can customize the style 

//
Tip is prompt, type: 'success' success is information, 'danger' is failure information , 'info' is general information, 'warning' warning message function ShowTip (Tip, type) { var $ Tip = $ ( 'Tip #' ); IF ($ tip.length == 0 ) { // set styles, It can also be defined in css file $ tip = $ ( '<span id = "tip" style = "position: absolute; top: 50px; left: 50%; z-index: 9999; height: 35px; padding: 0 20px ; Line-height: 35px; "> </ span> ' ); $ ( ' body ' ) .append ($ Tip); } $ tip.stop ( to true).prop('class', 'alert alert-' + type).text(tip).css('margin-left', -$tip.outerWidth() / 2).fadeIn(500).delay(2000).fadeOut(500); } function ShowMsg(msg) { ShowTip(msg, 'info'); } function ShowSuccess(msg) { ShowTip(msg, 'success'); } function ShowFailure(msg) { ShowTip(msg, 'danger'); } function ShowWarn(msg, $focus, clear) { ShowTip(msg, 'warning'); if ($focus) {      $focus.focus();   if (clear) $focus.val('');    } return false; }

 

Guess you like

Origin www.cnblogs.com/yaoqingzhuan/p/11564345.html