我正在尝试创建一个更新的标题,并与bxSlider之外的每个传递幻灯片相对应。我正在尝试使用getCurrentSlide();要做到这一点,但在第二张幻灯片之后,标题会卡在“Caption TWO”上。
这是我的JavaScript:
var bxSlider = $('.bxslider').bxSlider();
$(document).on('click', function(){
var current = bxSlider.getCurrentSlide();
if (current = 0) {
$('p.custom_caption').html('Caption ONE');
}
else if (current = 1) {
$('p.custom_caption').html('Caption TWO');
}
else if (current = 2) {
$('p.custom_caption').html('Caption THREE');
}
else if (current = 3) {
$('p.custom_caption').html('Caption FOUR');
}
});
非常感谢任何帮助!谢谢!
答案 0 :(得分:0)
dm4web是对的(见评论) -
var bxSlider = $('.bxslider').bxSlider();
$(document).on('click', function(){
var current = bxSlider.getCurrentSlide();
if (current == 0) {
$('p.custom_caption').html('Caption ONE');
}
else if (current == 1) {
$('p.custom_caption').html('Caption TWO');
}
else if (current == 2) {
$('p.custom_caption').html('Caption THREE');
}
else if (current == 3) {
$('p.custom_caption').html('Caption FOUR');
}
});