我使用Owl Carousel创建了一个带有帖子的基于幻灯片的页面。我对其实现了数据哈希,除了我需要一个将类添加到当前哈希项的功能之外,它可以完美地工作,因此,当更改哈希位置或接收外部哈希链接时,该项将添加一个类。
这是我的代码,我使用Owl Carousel v2.3.4,并且网站在wordpress中:
$('#post_top_slider').owlCarousel({
loop: false,
margin: 0,
nav: true,
dots: false,
URLhashListener: true,
startPosition: 'URLHash',
addClassActive: true,
autoplayHoverPause: true,
responsive: {
0: {
items: 1
},
600: {
items: 2
},
1000: {
items: 3
}
}
});
$('#post_top_slider .owl-stage .owl-item').first().addClass('ps_actve');
$('#post_top_slider .owl-stage .owl-item').click(function(event) {
$(this).siblings('.owl-item').removeClass('ps_actve');
$(this).addClass('ps_actve');
var tab_id = $(this).children('.pts_item').attr('data-id');
//alert(tab_id);
$(tab_id).siblings('.ptsd_item').hide();
$(tab_id).show();
});
我需要添加到哈希项的类是“ ps_actve”。网站是here。
答案 0 :(得分:0)
问题消失了。我只是将代码放在owlcarousel.js中的第3307行下面:
Customer