Home > Mobile >  How to use activeIndex in Swiper JS, how to make second slider active, not the first one
How to use activeIndex in Swiper JS, how to make second slider active, not the first one

Time:11-18

var swiper = new Swiper(".swiperEvent", { slidesPerView: "auto", centeredSlides: true, spaceBetween: 115, pagination: { el: ".swiper-pagination", clickable: true, }, navigation: { nextEl: ".swiper-button-next", prevEl: ".swiper-button-prev", }, }); }

CodePudding user response:

Based on the docs, you can use initialSlide:

https://swiperjs.com/swiper-api#param-initialSlide

var swiper = new Swiper(".swiperEvent", { 
  slidesPerView: "auto",
  centeredSlides: true,
  spaceBetween: 115,
  pagination: { el: ".swiper-pagination", clickable: true, }, 
  navigation: { nextEl: ".swiper-button-next", prevEl: ".swiper-button-prev" }, 
  initialSlide: 1 // HERE
})
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

  • Related