Hyper Learn
Hyper Learn

Reputation: 45

how to use any owl.carousel?

how can i use any owl.carousel in my template html ?

this is my source. i repeat cod but Does not work :

...

        <div id="owl-demo" class="owl-carousel">

          <div class="item"><h1>1</h1></div>
          <div class="item"><h1>2</h1></div>
          <div class="item"><h1>3</h1></div>
          <div class="item"><h1>4</h1></div>
          <div class="item"><h1>5</h1></div>
          <div class="item"><h1>6</h1></div>
          <div class="item"><h1>7</h1></div>
          <div class="item"><h1>8</h1></div>
          <div class="item"><h1>9</h1></div>
          <div class="item"><h1>10</h1></div>
          <div class="item"><h1>11</h1></div>
          <div class="item"><h1>12</h1></div>

        </div>

     <div id="owl-demo" class="owl-carousel">

          <div class="item"><h1>1</h1></div>
          <div class="item"><h1>2</h1></div>
          <div class="item"><h1>3</h1></div>
          <div class="item"><h1>4</h1></div>
          <div class="item"><h1>5</h1></div>
          <div class="item"><h1>6</h1></div>
          <div class="item"><h1>7</h1></div>
          <div class="item"><h1>8</h1></div>
          <div class="item"><h1>9</h1></div>
          <div class="item"><h1>10</h1></div>
          <div class="item"><h1>11</h1></div>
          <div class="item"><h1>12</h1></div>

        </div>

... this is my source : [https://drive.google.com/file/d/1NhADd8J0ARRzRAutfs5u-_zrYqdg5nS3/view?usp=sharing][1]

Upvotes: 2

Views: 496

Answers (1)

Zachary
Zachary

Reputation: 300

Check this out: https://jsfiddle.net/97j9gmtm/2/ You need to put the "owl-carousel" class on your carousels, independently a number of them.

$(document).ready(function(){
    $('.owl-one').owlCarousel({
        loop:true,
        margin:10,
        nav:true,
        responsive:{
            0:{
                items:1
            },
            600:{
                items:2
            },
            1000:{
                items:3
            }
        }
    });

    $('.owl-two').owlCarousel({
        loop:true,
        margin:10,
        nav:true,
        responsive:{
            0:{
                items:1
            },
            600:{
                items:2
            },
            1000:{
                items:3
            }
        }
    });

    $('.owl-three').owlCarousel({
        loop:true,
        margin:10,
        nav:true,
        responsive:{
            0:{
                items:1
            },
            600:{
                items:2
            },
            1000:{
                items:3
            }
        }
    });
});

Or if they are all going to have them same settings you could use:

$(".owl-carousel").each(function(){
    $(this).owlCarousel({
      loop:true,
        margin:10,
        nav:true,
        navText: [&#x27;next&#x27;,&#x27;prev&#x27;],
        responsive:{
            0:{
                items:1
            },
            600:{
                items:1
            },
            1000:{
                items:1
            }
        }
    });
  });

Upvotes: 1

Related Questions