1
2
3
4
5
6
7
8
9
10
11
12
Use
// Required jQuery & OwlCarousel 2
<script src="jquery.js"></script>
<script src="owl.carousel.js"></script>
// OwlCarousel 2 - Filter
<script src="https://huynhhuynh.github.io/owlcarousel2-filter/dist/owlcarousel2-filter.min.js"></script>
Html
<nav class="owl-filter-bar">
<a href="#" class="item" data-owl-filter="*">All</a>
<a href="#" class="item" data-owl-filter=".red">Red</a>
<a href="#" class="item" data-owl-filter=".blue">Blue</a>
</nav>
<div class="owl-carousel owl-theme">
<div class="item red"><h4>1</h4></div>
<div class="item red"><h4>2</h4></div>
<div class="item blue"><h4>3</h4></div>
<div class="item"><h4>4</h4></div>
<div class="item"><h4>5</h4></div>
<div class="item red"><h4>6</h4></div>
<div class="item"><h4>7</h4></div>
<div class="item"><h4>8</h4></div>
<div class="item blue"><h4>9</h4></div>
<div class="item"><h4>10</h4></div>
<div class="item blue"><h4>11</h4></div>
<div class="item"><h4>12</h4></div>
</div>
OwlCarousel 2 - Init
var owl = $('.owl-carousel').owlCarousel({
loop:true,
margin:10,
nav:true,
responsive:{
0:{
items:1
},
600:{
items:3
},
1000:{
items:5
}
}
})
OwlCarousel 2 - Filter
// owl.owlcarousel2_filter( '.blue' );
$( '.owl-filter-bar' ).on( 'click', '.item', function() {
var $item = $(this);
var filter = $item.data( 'owl-filter' )
owl.owlcarousel2_filter( filter );
} )