jQuery whole HTML page load with spinner

前端 未结 4 702
旧时难觅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:34

    First do you mean everything in the between the body tags? The best way to do the spinning gift is to add a class that defines the gif as none repeat and centered. The remove the class when the page is ready to be shown.

    $('body').addClass('loading')
    $('body').removeClass('loading')
    

    This is always the best technique because if you submit something then try to add the gif through a DOM addition some browsers will not do it because the page has been submitted.

提交回复
热议问题