I am using Swiper's Loop Mode to have a slide with pagination and navigation.
What I would like to do is change the background-color of body
, depending on the slide the user is at (so, say, I am on slide 2, body background-color is #FFF, I am on slide 3, it is #000, etc).
Any ideas on how to do this?
Demo listen transitions and change background related to index of slide
swiper.on('transitionEnd', function (e) {
if(this.activeIndex==2){
document.querySelector(".swiper-slide-active").style.background = 'red';
}
});