I need to implement the following: category buttons + category gallery
I have several categories on my site and a gallery of images for each. On the front, I'll create buttons with the categories and just below a slider .
I need to click on a category button, stay in the slider, only the images for that category.
Ps: Ignore the 'all' button because it will not have
Here are the codes I already have:
$("#Glide").glide({
type: "carousel",
autoplay: 0
});
$(".filter-button").click(function () {
var value = $(this).attr('data-filter');
if (value == "all") {
$('.filter').show();
}
else {
$(".filter").not('.' + value).hide();
$('.filter').filter('.' + value).show();
}
});
.glide {
margin: 0 auto;
width: 300px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/glide.core.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/glide.theme.css">
<title>Gallery Filter By Category</title>
</head>
<body>
<div align="center">
<button class="filter-button" data-filter="all">All</button>
<button class="filter-button" data-filter="c1">Category 1</button>
<button class="filter-button" data-filter="c2">Category 2</button>
<button class="filter-button" data-filter="c3">Category 3</button>
<button class="filter-button" data-filter="c4">Category 4</button>
</div>
<br>
<br>
<br>
<br>
<br>
<div id="Glide" class="glide">
<div class="glide__arrows">
<button class="glide__arrow prev" data-glide-dir="<">prev</button>
<button class="glide__arrow next" data-glide-dir=">">next</button>
</div>
<div class="glide__wrapper">
<ul class="glide__track">
<li class="glide__slide filter c1">
<img src="https://fakeimg.pl/300x300/a4c400/?text=category1&font=lobster&font_size=55"></li><liclass="glide__slide filter c3">
<img src="https://fakeimg.pl/300x300/0050ef/?text=category3&font=lobster&font_size=55"></li><liclass="glide__slide filter c1">
<img src="https://fakeimg.pl/300x300/a4c400/?text=category1&font=lobster&font_size=55"></li><liclass="glide__slide filter c2">
<img src="https://fakeimg.pl/300x300/00aba9/?text=category2&font=lobster&font_size=55"></li><liclass="glide__slide filter c3">
<img src="https://fakeimg.pl/300x300/0050ef/?text=category3&font=lobster&font_size=55"></li><liclass="glide__slide filter c4">
<img src="https://fakeimg.pl/300x300/d80073/?text=category4&font=lobster&font_size=55"></li><liclass="glide__slide filter c2">
<img src="https://fakeimg.pl/300x300/00aba9/?text=category2&font=lobster&font_size=55"></li></ul></div></div><scriptsrc="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/glide.js"></script>
</body>
</html>