刷新特定的多猫头鹰旋转木马点击处理程序



我有更多同类的猫头鹰旋转木马。但问题是如何瞄准当前滑块并点击刷新下一个滑块,谁将是当前滑块。

我的处理者:

$(".office-gallery").each(function (obj, index) {
$(this).owlCarousel({...});
});

$("button").on("click", function () {
targetCurrentOrSpecifficIndexSlider.trigger("refresh.owl.carousel"); // or .trigger("to.owl.carousel", [0, 1, true]);
});

我已经尝试设置变量:

let outTarget = null;
$(".office-gallery").each(function (obj, index) {
outTarget = $(this).owlCarousel({...});
});
...
outTarget[0(or index)].trigger("refresh.owl.carousel"); // or .trigger("to.owl.carousel", [0, 1, true]);

知道怎么解决这个问题吗?谢谢

您可以通过jquery使用closest((find((函数来解决它:

(添加转盘和按钮的容器(

$("button").on("click", function () {
$(this).closest(".CarouselContainer").find(".office-gallery").trigger("refresh.owl.carousel");
});

最新更新