2

How do I get the ID of the current element(s) visible with Owl Carousel v2?

$('.owl-carousel').on('dragged.owl.carousel', function(e) {
   // get id; only one slide visible in this case

});

<div class="owl-carousel owl-theme">
    <div class="item" id='1'><h4>1</h4></div>
    <div class="item" id='2'><h4>2</h4></div>
    <div class="item" id='3'><h4>3</h4></div>
    <div class="item" id='4'><h4>4</h4></div>
    <div class="item"><h4>5</h4></div>
    <div class="item"><h4>6</h4></div>
    <div class="item"><h4>7</h4></div>
    <div class="item"><h4>8</h4></div>
    <div class="item"><h4>9</h4></div>
    <div class="item"><h4>10</h4></div>
    <div class="item"><h4>11</h4></div>
    <div class="item"><h4>12</h4></div>
</div>

The callback would return "1" if the first slide is visible.

Caleb Pitman
  • 1,105
  • 1
  • 12
  • 24

0 Answers0