Answer the question
In order to leave comments, you need to log in
How to implement class change by Jquery array index?
Hello. There is a slick slider. I want to make this function, when activated, change the class of another block according to the index of the called function.
That is, if the index is 1, then the block has a new class class_1, if the index is 2, then it changes to class_2.
or as the second option, so that it is not the class that changes, but the background property: URL(img-$`{1}.png).
With jQuery I'm really bad :D.
$('.first-screen__slider').on('beforeChange', function (event, slick, currentSlide, nextSlide) {
console.log(nextSlide);
$('.first-screen').toggleClass(`first-screen__sliderContent_ ${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