猫头鹰旋转木马2导航幻灯片

时间:2015-02-19 11:25:16

标签: jquery owl-carousel

我正在使用 Owl Carousel 2 jquery插件,并尝试在幻灯片中包含导航按钮。我的HTML非常简单:

<div class="owl-carousel">    
<div>
  <p>Slide 1 Lorem ipsum dolor sit amet, consectetur adipisicing elit. Placeat quisquam rem assumenda, ullam, beatae earum animi magnam! Reiciendis, laboriosam, itaque.</p>

  <div class="customNavigation">
    <a class="prev">Previous</a>
    <a class="next">Next</a>
  </div>

</div>

<div>
  <p>Slide 2 Lorem ipsum dolor sit amet, consectetur adipisicing elit. Placeat quisquam rem assumenda, ullam, beatae earum animi magnam! Reiciendis, laboriosam, itaque.</p>

  <div class="customNavigation">
    <a class="prev">Previous</a>
    <a class="next">Next</a>
  </div>

</div>

<div>
  <p>Slide 3 Lorem ipsum dolor sit amet, consectetur adipisicing elit. Placeat quisquam rem assumenda, ullam, beatae earum animi magnam! Reiciendis, laboriosam, itaque.</p>

  <div class="customNavigation">
    <a class="prev">Previous</a>
    <a class="next">Next</a>
  </div>

</div>

然后我就像这样调用插件:

$(document).ready(function(){    
    $('.owl-carousel').owlCarousel({
        loop:true,
        items: 1,
    })      
});

现在我只需要获取链接即可使用该插件!任何帮助非常感谢

1 个答案:

答案 0 :(得分:13)

希望这可以帮助你交配。

$('.owl-carousel').owlCarousel({
    loop: true,
    items: 1,
});
owl = $('.owl-carousel').owlCarousel();
$(".prev").click(function () {
    owl.trigger('prev.owl.carousel');
});

$(".next").click(function () {
    owl.trigger('next.owl.carousel');
});

小提琴here