我正在尝试使用 jQuery Lazy Load插件,但它说
You can also use plugin for images inside scrolling container, such as div with scrollbar. Just pass the container as jQuery object.
好的,我的问题是:我有一个 div 嵌套,scrollable 在外面,但图像在内部 div 中。示例:
<div class="outer">
...
<div class="middle">
<div class="inner">
<img ... />
...
</div>
<div class="inner">
<img ... />
...
</div>
<div class="inner">
<img ... />
...
</div>
</div>
我怎样才能对这些家伙进行延迟加载?
最佳答案
我遇到了完全相同的问题。这是修复它的 scrollable
示例。
演示 http://jsfiddle.net/dragoncrew/SHGwe/1/
var ds_loaded = false,
top = $("#disqus_thread").offset().top;
window.disqus_developer = 1;
window.disqus_shortname = 'dragoncrew';
function check(){
if ( !ds_loaded && $(window).scrollTop() + $(window).height() > top ) {
$.ajax({
type: "GET",
url: "http://" + disqus_shortname + ".disqus.com/embed.js",
dataType: "script",
cache: true
});
ds_loaded = true;
}
}
$(window).scroll(check);
check();
关于jQuery 延迟加载 : Div inside Div inside Div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20078832/