Owl Carousel 2在Click上添加更改项目编号

时间:2018-05-10 06:30:47

标签: jquery owl-carousel-2

我有什么方法可以更改猫头鹰轮播项目限制点击。因为我正在处理网格和列表视图而不重新加载,我想在点击列表视图按钮上更改Owl Carousel项目。就像我最近在网格giew上显示的2个项目一旦我点击了列表视图,它将只显示1个项目。

<ul class="list-unstyled view-holder">
    <li class="view-box grid-view active">
        <a href="javascript:;">Grid View</a>
    </li>
    <li class="view-box list-view">
        <a href="javascript:;">List View</a>
    </li>
</ul>

<div class="owl-carousel feature-carousel">
    <div class="item"> 1 </div>
    <div class="item"> 2 </div>
    <div class="item"> 3 </div>
    <div class="item"> 4 </div>
</div>

var itemList = 2;

var $owlFeatureSlider = $(".feature-carousel");

$owlFeatureSlider.owlCarousel({
    rtl: rtlVal
    , loop: false
    , margin: 30
    , nav: false
    , items: itemList
});

$(".list-view").click(function () {

    $owlFeatureSlider.trigger('refresh.owl.carousel');

    if(itemList == 2){
       var itemList = 1;
    }

});

0 个答案:

没有答案