我使用OWL Carousel,試圖lazyLoad後添加.border-red
類<div class="item">
,意味着調用這個函數lazyLoad afterLazyLoad
例後:$(".item").addClass("border-red");
懶加載時。意思是在OWLCarousel lazyLoaded之後添加類函數執行。添加類OWL的旋轉木馬afterLazyLoad
JS
$(document).ready(function() {
$("#owl-demo").owlCarousel({
items : 4,
lazyLoad : true,
navigation : true
});
});
HTML
<div id="owl-demo" class="owl-carousel">
<div class="item"><img class="lazyOwl" data-src="assets/owl1.jpg" alt="Lazy Owl Image"></div>
<div class="item"><img class="lazyOwl" data-src="assets/owl1.jpg" alt="Lazy Owl Image"></div>
<div class="item"><img class="lazyOwl" data-src="assets/owl2.jpg" alt="Lazy Owl Image"></div>
<div class="item"><img class="lazyOwl" data-src="assets/owl3.jpg" alt="Lazy Owl Image"></div>
<div class="item"><img class="lazyOwl" data-src="assets/owl5.jpg" alt="Lazy Owl Image"></div>
</div>
這裏是OWLCarousel Options and Callbacks
OWLCarousel demo>
如何addclassØ功能後執行WLCarousel lazyLoaded?
您需要設置'afterLazyLoad'爲'真',你的選擇,就像你'lazyLoad'和'做導航'。您應該能夠通過此選項更新訪問回調函數。 –
@TylerSloan嗨,謝謝,但如何訪問回調函數? – Aariba
@ vijayP的回答很好。 –