jQuery toast 淡入淡出提示


#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);
        }
  });	


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM