#toastTip{
    position: fixed;
    top: 44%;left:50%;transform: translateX(-50%);
    min-width: 80px;
    max-width: 180px;
    min-height: 18px;
    padding: 10px;
    line-height: 18px;
    text-align: center;
    font-size: 16px;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 5px;
    display: none;
    z-index: 999;
}

/* toast 提示 
   $("#toastTip").showMessage('网络错误,请稍后重试', 1400);
   绑定在window上,使用方法:showMessage('提示信息', time) window.showMessage = function() {}
*/
  $.fn.extend({
    showMessage: function( $msg, $time ){
        $time = $time === 0 ? 0 : ($time || 1000);
        var oDiv = document.createElement("div");
        oDiv.setAttribute("id", "toastTip");
        var oBody = document.getElementsByTagName('body')[0];
        oBody.append(oDiv);
        $('#toastTip').text( $msg );
        $('#toastTip').fadeIn();
        setTimeout(function() {
            $('#toastTip').fadeOut(function(){
              $('#toastTip').remove();
            });
        }, $time);
    }
});	

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2021-09-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
  • 2021-11-06
  • 2021-04-03
  • 2021-06-24
相关资源
相似解决方案