jQuery lazyload插件和回调函数 [英] Jquery lazyload plugin and callback function

查看:299
本文介绍了jQuery lazyload插件和回调函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从此网站 http://www.appelsiini.net/projects/lazyload 下载jQuery lazyload插件.

i download jquery lazyload plugin from this site http://www.appelsiini.net/projects/lazyload.

从他们的文档中,我还没有发现可以通过lazyload插件使用或不使用任何回调.

from their doc i have not found that one can use any callback or not with lazyload plugin.

假设我的html看起来像

suppose my html look like

<div id="gallery" class="busy"><img src="blah.jpg" /></div>
<div id="gallery" class="busy"><img src="blah2.jpg" /></div>
<div id="gallery" class="busy"><img src="blah3.jpg" /></div>

我的脚本喜欢

$("#gallery img").lazyload();

class busy只会在div的中心设置一个忙碌的图像.所以我需要一个回调,并且从回调中需要检测图像下载是否完成(如果完成),那么我只需从图像标记的相应父div中删除该类即可.

class busy will just set a busy image at the center of div. so i need a callback and from the callback i need to detect image download completed or not if completed then i just remove the class from corresponding parent div of image tag .

因此,请向我展示使用lazyload实现回调的方法,并且还需要示例代码,通过该示例代码,我可以从图像标签的相应父div中删除该类.

so please show me the way to implement callback with lazyload and also need sample code by which i can remove the class from corresponding parent div of image tag .

谢谢

推荐答案

我有同样的问题.做了一些搜索,来到这里,找到了答案.这是我拥有的水,并且为我工作:

I had the same question. Did some searching, came here, and found the answer. This is wat I have, and works for me:

$(this).lazyload({
    effect : 'fadeIn',
    load : function()
    {
        console.log($(this)); // Callback here
    }
});

希望这会有所帮助!

这篇关于jQuery lazyload插件和回调函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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