我正在建立带有滑动滑块(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();
答案 0 :(得分:0)
在此处查看文档:{{3}}
portfolioSlider.on('transitionEnd', function() {
var nextTitle = $('.swiper-slide-next').find('.title');
if (nextTitle.length > 0) {
$('.js-portfolio-slider__next').text(nextTitle);
}
})
应该做到这一点。 'swiper-slide-next'应该是标记中下一张幻灯片的类
答案 1 :(得分: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