document.addEventListener("DOMContentLoaded", function () {
const sliders = document.querySelectorAll(".custom-slider");
sliders.forEach((sliderContainer) => {
const slides = sliderContainer.querySelectorAll(".slide");
const prevButton = sliderContainer.nextElementSibling.querySelector(".prev");
const nextButton = sliderContainer.nextElementSibling.querySelector(".next");
let index = 0;
const updateSlider = () => {
slides.forEach((slide, i) => {
slide.style.transform = `translateX(-${index * 100}%)`;
});
};
prevButton.addEventListener("click", () => {
index = (index > 0) ? index - 1 : slides.length - 1;
updateSlider();
});
nextButton.addEventListener("click", () => {
index = (index + 1) % slides.length;
updateSlider();
});
});
});