39

I'm using the Owl Carousel on my site. According to their documentation, this piece of JavaScript should work:

<script>
$("#intro").owlCarousel({

// Most important owl features

//Autoplay
autoPlay : 5000,
stopOnHover : false
)}
</script>

But for some reason it will not autoplay. Here is the HTML of the slider:

<div id="intro" class="owl-carousel">
    <div class="item first">
      <div class="container">
        <div class="row">
          <div class="carousel-caption-left colour-white">
            <h2>Title Text</h2>
            <h1>Sub title text here.</h1>
            <p>If you like you can even add a sentence or two here.</p>
          </div>
        </div>
      </div>
      <div class="overlay-bg"></div>
    </div>
    <div class="item second">
      <div class="container">
        <div class="carousel-caption-left colour-white">
          <h2>Title Text</h2>
          <h1>Sub title text here.</h1>
          <p>If you like you can even add a sentence or two here.</p>
        </div>
      </div>
      <div class="overlay-bg"></div>
    </div>
    <div class="item third">
      <div class="container">
        <div class="carousel-caption-left colour-white">
          <h2>Title Text</h2>
          <h1>Sub title text here.</h1>
          <p>If you like you can even add a sentence or two here.</p>
        </div>
      </div>
      <div class="overlay-bg"></div>
    </div>
</div>
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
thedoggydog
  • 459
  • 1
  • 4
  • 10

15 Answers15

89

Yes, its a typing error.

Write

autoPlay

not

autoplay

The autoplay-plugin code defines the variable as "autoPlay".

Henri
  • 3
  • 2
43

You are may be on the wrong owl's doc version.

autoPlay is for 1st version

autoplay is for 2nd version
1ronmat
  • 1,147
  • 8
  • 15
22

Changing autoplay to autoPlay alone did not work for me. What did the trick was to add autoplaySpeed and autoplayTimeout properties and set them to the same value, like this:

$(document).ready(function(){
    var owl = $(".owl-carousel");
    owl.owlCarousel({
        items: 1,
        autoplay: true,
        autoPlaySpeed: 5000,
        autoPlayTimeout: 5000,
        autoplayHoverPause: true
    });
});

Here's a working demo: JS Bin

More info about this can be found here: https://github.com/smashingboxes/OwlCarousel2/issues/234

Veegish Ramdani
  • 321
  • 3
  • 7
9

add this

owl.trigger('owl.play',6000);
laalto
  • 150,114
  • 66
  • 286
  • 303
M Arfan
  • 4,384
  • 4
  • 29
  • 46
5

You should set both autoplay and autoplayTimeout properties. I used this code, and it works for me:

$('.owl-carousel').owlCarousel({
                autoplay: true,
                autoplayTimeout: 5000,
                navigation: false,
                margin: 10,
                responsive: {
                    0: {
                        items: 1
                    },
                    600: {
                        items: 2
                    },
                    1000: {
                        items: 2
                    }
                }
            })
Hossein Hashemi
  • 150
  • 1
  • 5
5

With version 2.3.4, you need the to add the owl.autoplay.js plugin. Then do the following

var owl = $('.owl-carousel');
owl.owlCarousel({
   items:1, //how many items you want to display
    loop:true,
    margin:10,
    autoplay:true,
    autoplayTimeout:10000,
    autoplayHoverPause:true
});
Sasha Tsukanov
  • 1,025
  • 9
  • 20
israel
  • 181
  • 1
  • 6
  • I'm using 2.3.4, and I didn't find it was necessary to load owl.autoplay.js. Just loading owl.carousel.min.js (and jquery and the css files) worked fine. – createscape Nov 13 '20 at 22:31
  • @createscape Are you sure owl.autoplay.js is not cached in your browser. Maybe you can try another browser and see if it would still work. – israel Nov 25 '20 at 11:15
  • I have checked in another browser and it is working without loading the separate owl.autoplay.js file. – createscape Nov 26 '20 at 20:45
4

This code should work for you

$("#intro").owlCarousel ({

        slideSpeed : 800,
        autoPlay: 6000,
        items : 1,
        stopOnHover : true,
        itemsDesktop : [1199,1],
        itemsDesktopSmall : [979,1],
        itemsTablet :   [768,1],
      });
Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
frank john
  • 49
  • 2
3

Just a Typing Error,

<script>
$("#intro").owlCarousel({

// Most important owl features

//Autoplay
autoPlay : 5000,
stopOnHover : false
)} ----- TYPO
</script>

It should be-

<script>
$("#intro").owlCarousel({

// Most important owl features

//Autoplay
autoPlay : 5000,
stopOnHover : false
}) ----- Correct
</script>
Neil
  • 402
  • 6
  • 18
2

Your Javascript should be

<script>
$("#intro").owlCarousel({

// Most important owl features

//Autoplay
autoplay: false,
autoplayTimeout: 5000,
autoplayHoverPause: true
)}
</script>
XIMRX
  • 2,130
  • 3
  • 29
  • 60
2

In my case autoPlay not working but autoplay is working fine

I only used this

<script src="plugins/owlcarousel/owl.carousel.js"></script>

no owl.autoplay.js is need it & my owl carousel version is @version 2.0.0

hope this thing help you :)

Zaheer Ahmad
  • 176
  • 2
  • 11
1

Setting autoPlay: true didn't work for me. But on setting autoPlay: 5000 it worked.

aryalprakash
  • 340
  • 2
  • 14
1

If you using v1.3.3 then use following property

autoPlay : 5000

Or using latest version then use following property

autoPlay : true
Ahmed Awan
  • 347
  • 3
  • 9
1

Owl Carousel version matters a lot, as of now (2nd Aug 2020) the version is 2.3.4 and the right options for autoplay are:

$(".owl-carousel").owlCarousel({
    autoplay : true,
    autoplayTimeout: 3000,//Autoplay interval timeout.
    loop:true,//Infinity loop. Duplicate last and first items to get loop illusion.
    items:1 //The number of items you want to see on the screen.
});

Read more Owl configurations

ovicko
  • 2,242
  • 3
  • 21
  • 37
0
  1. First, you need to call the owl.autoplay.js.

  2. this code works for me : owl.trigger('play.owl.autoplay',[1000]);

Kako Sabolo
  • 109
  • 2
0

I had the same problem and couln't find the solution. Finally I realized, that with owlcarousel ver. 2.3.4 I have to include not only owl.carousel.js, but owl.autoplay.js file too.

Ondrej
  • 1