Javascript jQuery:在执行代码之前,等待幻灯片完成
我想在执行代码之前等待滑动动画完成,如下所示:Javascript jQuery:在执行代码之前,等待幻灯片完成,javascript,jquery,Javascript,Jquery,我想在执行代码之前等待滑动动画完成,如下所示: $('#blueimp-gallery').on('slide', function (event, index, slide) { $(this).find('.modal-citation') .text($('#links a').eq(index).data('citation')); }); 我试过几种方法,但都不管用 $('#blueimp-gallery').on('slide', function (eve
$('#blueimp-gallery').on('slide', function (event, index, slide) {
$(this).find('.modal-citation')
.text($('#links a').eq(index).data('citation'));
});
我试过几种方法,但都不管用
$('#blueimp-gallery').on('slide', function (event, index, slide) {
$(this).find('.modal-citation')
.text($('#links a').eq(index).data('citation')).delay(3000); // didn't work
});
$('#blueimp-gallery').on('slide', function (event, index, slide) {
setTimeout(function () {
$(this).find('.modal-citation')
.text($('#links a').eq(index).data('citation')); // didn't work
}, 1000);
});
正确的方法是什么?您应该能够在插件选项中设置:
// Callback function executed after the slide change transition.
// Is called with the gallery instance as "this" object and the
// current index and slide as arguments:
onslideend: function() {
// Do something
}
摘自:您在幻灯片中使用的库/插件是什么?可能值得创建一个codepen.io示例。回调函数在初始函数完成之前不会执行。你根本不需要setTimeout。我正在使用blueimp的引导图像库。当你发布你的评论时,我也在写同样的评论!在初始操作完成之前,不会执行回调