jQuery的 - 等到背景图像已加载然后显示元素 [英] jQuery - Wait till background images have loaded then show element

查看:243
本文介绍了jQuery的 - 等到背景图像已加载然后显示元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也找了几个地方,有人告诉他如何做到这一点,但是这是不是超级不方便或只是没有工作。(球员自己的例子没有工作..)

I did find a few places where it was told how to do this but it was either super inconvenient or just didnt work.. ( the guys own example did not work.. )

基本上我有背景图片,我想在同一时间,而不是让他们来显示加载到文档中当过他们请...

Basically i have background images that i would like to show at the same time instead of letting them to load in to the document when ever they please...

我不必然需要他们先装入或任何,但要等到特定的背景图片加载,然后展示自己的父母DIV ..

I dont necessarily need them to be loaded first or anything but to wait until specific background images load up and then show their parent div..

此外,如果其可能的..这将使如果这些背景图片可以被定义为通过类加载很大的区别,而不是指定实际的图像名称...像

Also if its possible.. it would make big difference if those background images could be defined to be loaded through classes rather than specifying the actual image name... like

.load-BG〜后台负载〜表演元素。

.load-bg ~ background load ~ show element..

我是深远的月亮,或者这是可行的?

Am i reaching for the moon or is this doable?

推荐答案

我的插件, waitForImages ,允许您附加回调时图像已经加载。

My plugin, waitForImages, allows you to attach callbacks when images have loaded.

它支持在CSS中引用的图像。

It supports images referenced in the CSS.

$('#some-container').waitForImages({
    waitForAll: true,
    finished: function() {
        // Loaded all images referenced in CSS.
    }
});

这篇关于jQuery的 - 等到背景图像已加载然后显示元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆