我正在使用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();
请参阅此处的文档: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'应该是标记中下一张幻灯片的类
使用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