前端小结(4)---- 页面加载loding....

/*正在加载*/
function showLoading(elem) {
    var html = '<div class="loading"><div id="over" class="over"></div><div id="layout" class="layout"><img src="../../assets/img/loading.gif" /></div></div>'
    if (elem) {
        elem.after(html);
    }

    $("#over").css("display", "block");
    $("#layout").css("display", "block");
}

function hideLoading(elem) {
    elem.next().remove();
}
<img src="../../assets/img/loading.gif" />中替换成对应的加载图标

对应css:
.over {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(2, 2, 2, 0.15);
    opacity: 0.5;
    z-index: 1000;
}

.layout {
    display: none;
    position: absolute;
    top: 28%;
    left: 40%;
    width: 20%;
    height: 20%;
    z-index: 1001;
    text-align: center;
}

 

posted @ 2015-10-14 16:57  x&y  阅读(264)  评论(0编辑  收藏  举报