Swiper滑块自定义上一个/下一个导航

问题描述 投票:0回答:2

我正在使用swiper滑块(https://idangero.us/swiper/)列出组合项目构建wordpress网站。我需要的是包含下一张幻灯片标题的下一个按钮。那可能吗?像这样:rough preesentation

这是代码:

var swiperOptions = {
    loop: true,
    speed: 1000,
}

function portfolioSlider() {
    var portfolioSlider = new Swiper('.js-portfolio-slider', swiperOptions);
    $(document).on('click', '.js-portfolio-slider__next', function(e) {
        e.preventDefault();
        portfolioSlider.slideNext();
    });
}

portfolioSlider();
javascript wordpress swiper
2个回答
0
投票

请参阅此处的文档:https://idangero.us/swiper/api/#events

portfolioSlider.on('transitionEnd', function() {
   var nextTitle = $('.swiper-slide-next').find('.title');
   if (nextTitle.length > 0) {
      $('.js-portfolio-slider__next').text(nextTitle);
   }
})

应该做的伎俩。 'swiper-slide-next'应该是标记中下一张幻灯片的类


0
投票

使用swiper.slides[index + 1].innerText获取内在内容

请参阅

penvar swiper = new Swiper('.swiper-container', {
  navigation: {
    nextEl: '.swiper-button-next',
    prevEl: '.swiper-button-prev',
  },
});

console.log(swiper.slides[1].innerText) visit https://codepen.io/harmeet2harry/pen/qvQWyO
© www.soinside.com 2019 - 2024. All rights reserved.