Owl Carousel 2 Navigation In Slide

Mike Harrison picture Mike Harrison · Feb 19, 2015 · Viewed 19k times · Source

I am using the Owl Carousel 2 jquery plugin, and am trying to have the navigation buttons contained within the slides. My html is very simple:

<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>

And then I am calling the plugin like so:

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

Now I just need to get the links to work with the plugin! Any help greatly appreciated

Answer

Outlooker picture Outlooker · Feb 19, 2015

Hope this might help you mate.

$('.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');
});

Fiddle here