码迷,mamicode.com
首页 > Web开发 > 详细

jQuery toast 淡入淡出提示

时间:2019-10-22 15:33:32      阅读:319      评论:0      收藏:0      [点我收藏+]

标签:extend   rgba   orm   padding   xtend   time   pen   name   lin   

#toast{
    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 提示 
       $("#toast").showMessage('网络错误,请稍后重试',1400);
    */
    $.fn.extend({
        showMessage: function( $msg, $time ){
            var oDiv = document.createElement("div");
            oDiv.setAttribute("id", "toast");
            var oBody = document.getElementsByTagName('body')[0];
            oBody.append(oDiv);
            $('#toast').text( $msg );
            $('#toast').fadeIn();
            setTimeout(function() {
                $('#toast').fadeOut();
            }, $time);
        }
  });   

jQuery toast 淡入淡出提示

标签:extend   rgba   orm   padding   xtend   time   pen   name   lin   

原文地址:https://www.cnblogs.com/lisaShare/p/11719458.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!