I am having a problem making this work. I know there is a solution for this problem, I think I solved it before, but I don't remember how. So..
I have JQuery code
$("#button-video").click(function () {
$("#image").addClass("show");
$("#image").removeClass("hide");
$("#video").addClass("hide");
$("#video").removeClass("show");
$("#button-gallery").removeClass("active");
$("#button-video").addClass("active");
});
$("#button-gallery").click(function () {
$("#video").addClass("show");
$("#video").removeClass("hide");
$("#image").addClass("hide");
$("#image").removeClass("show");
$("#button-video").removeClass("active");
$("#button-gallery").addClass("active");
});
HTML code
<div class="goods-image">
<a href="" data-lightbox="picture">
<div class="box" id="image">
<img src="" alt="product">
<div class="hover-eye">
</div>
</div>
</a>
<div class="box hide" id="video">
<iframe src="https://www.youtube.com/embed/tgbNymZ7vqY?controls=1">
</iframe>
</div>
<div class="image-box">
<div class="gallery active" id="button-video">
<p>Galerija</p>
</div>
<div class="video" id="button-gallery">
<p>Video</p>
</div>
</div>
</div>
There are multiple ids like #button-video_1, #video_1, #image_1, #button-video_2, #video_2, #image_2 and so on. Every one of them does the same thing, but for different picture or video. Because the list is long, how to make this code (above) work for all elements withouth copying and adding a number?