【问题标题】:load content and background image at the same time同时加载内容和背景图片
【发布时间】:2013-02-19 23:40:40
【问题描述】:

我正在使用 Ajax 加载一个外部 HTML,但是这个外部 html 有一个很大的背景图像,我如何才能在背景图像也加载之前显示一个加载器?

代码:

$( ".content" ).load("game.html", function() {
      });   

【问题讨论】:

    标签: jquery ajax loader


    【解决方案1】:

    试试这个:https://github.com/desandro/imagesloaded,用于检测图像何时加载的 JavaScript 代码

    您的代码将类似于:

    $( ".content" ).load("game.html", function() {
       $('.content').imagesLoaded(function () {
         remove loader
       });
    });
    

    【讨论】:

      猜你喜欢
      • 2017-08-17
      • 2015-08-24
      • 1970-01-01
      • 1970-01-01
      • 2016-12-14
      • 2020-04-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多