Answer the question
In order to leave comments, you need to log in
How to change slick slider caption text when swiping a slide?
There is js in which the slide counter works. When you swipe to the next slide, new text is added. Question: how to change the text again, when swiping back?
<span class="name-itm">Текст</span>
var $slider = $('.slider');
var sliderCounter = document.getElementsByClassName("slider-counter");
var nameItm = document.getElementsByClassName("name-itm");
var newText = "Новый текст";
if ($slider.length) {
var updateSliderCounter = function(slick, currentIndex) {
currentSlide = slick.slickCurrentSlide() + 1;
$(sliderCounter).text(currentSlide);
};
$slider.on('afterChange', function(event, slick, currentSlide, nextSlide) {
updateSliderCounter(slick, currentSlide, nextSlide);
nextSlide = newText;
$(nameItm).text(nextSlide);
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question