【问题标题】:add active class to owl-item in owl carousel向 owl carousel 中的 owl-item 添加活动类
【发布时间】:2018-02-21 08:21:07
【问题描述】:

我正在使用 owl carousel 作为缩略图查看器,并尝试向“owl-item”添加一个活动类。我已经按照 owl carousel 文档尝试了 afterAction 和 afterInit,它们都在第一个项目中添加了一个活动类,但在选择其他项目时都没有。

owldemo.owlCarousel({
items : 4,
responsive:false,
pagination: false,
navigation: true,
afterAction: function(el){
//afterinit: function(el)//same results

   this
   .$owlItems
   .removeClass('active')

   this
   .$owlItems 
   .eq(this.currentItem)
   .addClass('active')

 }
 }); 

【问题讨论】:

标签: jquery owl-carousel


【解决方案1】:

https://codepen.io/OwlFonk/pen/dnEga/

<button id="btn">Check Current Item</button>
$("#btn").click(function(){

  var active = carousel.find(".owl-item.active");

  alert(active.text())

})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多