jQuery whole HTML page load with spinner

前端 未结 4 776
旧时难觅i
旧时难觅i 2021-02-04 04:58

I am trying to something simple -- make a jQuery script that will wait to show the entire page, including all DIVs, text, and images. While the page is loading, instead of showi

4条回答
  •  甜味超标
    2021-02-04 05:54

    $(document).ready(...) fires as soon the DOM is loaded. This is too soon. You should use $(window).on('load', ...):

    JavaScript:

    $(window).on('load', function(){
        $('#cover').fadeOut(1000);
    })
    

    CSS:

    #cover {
        background: url("to/your/ajaxloader.gif") no-repeat scroll center center #FFF;
        position: absolute;
        height: 100%;
        width: 100%;
    }
    

    HTML:

    look at this jsFiddle: http://jsfiddle.net/gK9wH/9/

提交回复
热议问题