【发布时间】:2018-10-02 08:12:53
【问题描述】:
我使用 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。
【问题讨论】:
-
这与
owl无关!
标签: jquery owl-carousel