Untitled
unknown
plain_text
4 months ago
637 B
11
Indexable
$(document).ready(function() { const $sliderWrapper = $('.slider-wrapper'); const $slides = $('.slide'); const totalSlides = $slides.length; let currentIndex = 0; function showSlide(index) { const offset = -index * 100; $sliderWrapper.css('transform', `translateX(${offset}%)`); } $('.next').on('click', function() { currentIndex = (currentIndex + 1) % totalSlides; showSlide(currentIndex); }); $('.prev').on('click', function() { currentIndex = (currentIndex - 1 + totalSlides) % totalSlides; showSlide(currentIndex); }); });
Editor is loading...
Leave a Comment