我需要根据控制箭头或滑动来获取目标幻灯片项目(上一个或下一个)。
var slider = $('.owl-carousel');
slider.owlCarousel({
loop: true,
nav: true,
items: 1,
smartSpeed: 600
});
slider.on('change.owl.carousel', function(e) {
console.log($('.owl-item.active').html());
// I'm getting html of current slide, but not target slide
});
答案 0 :(得分:0)
slider.on('changed.owl.carousel', function(e) { // Action, when a carousel has changed
var target_index = e.property.value; // Index of target slide
if($.isNumeric(target_index)) { // if we swipe or clicking controls arrows (or dots) - we got numeric value, but on resize target_index is object, not a number. isNumeric need to prevent wrong value
$('.owl-item').eq(target_index).html(); // Getting target slide HTML
}
});