Search code examples
javascriptblogger

How to i make this slideshow auto playable


I'm having problem to make an autoplay slideshow.

$(document).ready(function() {
 var owl = $("#owl-wrapper");
 owl.owlCarousel({
  items: 8,
  itemsDesktop: [1000, 8],
  itemsDesktopSmall: [900, 6],
  itemsTablet: [600, 4],
  itemsMobile: false,
  navigation: false
 });
 $(".next").click(function() {
  owl.trigger('owl.next');
 })
 $(".prev").click(function() {
  owl.trigger('owl.prev');
 })
});

now im facing to add autoplay function


Solution

  • You should be able to do this

    $(document).ready(function() {
      var owl = $("#owl-wrapper");
      owl.owlCarousel({
        items: 8,
        itemsDesktop: [1000, 8],
        itemsDesktopSmall: [900, 6],
        itemsTablet: [600, 4],
        itemsMobile: false,
        navigation: false,
        autoplay:true,
        autoplayTimeout:1000, // set this to how long you want spent between slides
      });
      $(".next").click(function() {
        owl.trigger('owl.next');
      })
      $(".prev").click(function() {
        owl.trigger('owl.prev');
      })
    });
    

    By default autoPlay is false which is why you have to set it. You can read more about it here