有没有办法获得下一张幻灯片的图片标题,以便我们可以在下一张/上一张箭头上显示它?
这是我在开放回调函数中编写的脚本:
var num = $('.mfp-container .mfp-content .slide').attr('data-slideid');
num = parseInt(num);
console.log('current: '+num);
var prev = num - 1;
var next = num + 1;
console.log('next: '+next);
console.log('prev: '+prev);
if(num >= 5) { console.log('next disable'); } else {
var nextTitle = $('#explore-stay-'+next).text();
console.log(nextTitle);
$('.mfp-arrow-right').hover(function(){
$('.mfp-arrow-right').html(nextTitle+' Next');
},function(){
$('.mfp-arrow-right').html('Next');
});
}
if(num <= 0) { console.log('prev disable'); } else {
var prevTitle = $('#explore-stay-'+prev).text();
console.log(prevTitle);
$('.mfp-arrow-left').hover(function(){
$('.mfp-arrow-left').html(' Previous'+prevTitle);
},function(){
$('.mfp-arrow-left').html('Previous');
});
}
}
}
},itemNum); });