我懶加載圖像https://bm-translations.de 到目前爲止好,但現在我試圖實現它的背景圖像,以及它的點頭加載圖像(即目前沒有激活對於那些背景圖像)。lazyload背景圖像和正常圖像與jQuery庫
我試圖做它喜歡這裏沒有成功: http://jquery.eisbehr.de/lazy/example_load-background-images
那是我的HTML:
<div id="preise" class="lazybackground" data-src="./bilder/Hintergrund-rechner.png">
... text, text, text
</div>
這就是我的javascript:
//Lazyload Images with Threshold https://www.appelsiini.net/projects/lazyload
$(function() {
$("img.lazy").lazyload({
threshold : 400
});
});
$(function() {
$('.lazybackground').lazy();
});
什麼我做錯了嗎? Thanky爲你的幫助傢伙! :-)
PS:我也努力使滑塊來加載自己的形象懶(現在它太懶惰)我的問題是:Lazyloading images in horizontal slider
您還需要使用customLoader而不是默認加載器。由於這是頁面的背景圖像,所以閾值沒有多大意義。看看這個例子:http://jquery.eisbehr.de/lazy/example_use-custom-loaders – eenagy