我正在使用JQuery Flipster(https://github.com/drien/jquery-flipster)而我正试图获取一个模态窗口,仅为前面的current item
弹出窗口。我在下面使用了一个警告仅用于测试目的。
我可以通过这样做来实现行动:
$('.flipster__item--current').click(function(){
alert('Testing!');
});
我遇到的问题是.flipster_item--current
只在页面加载时才会停留在该类的第一个对象上,即使该类应用于轮播中的其他对象也是如此。
我发现Flipster在旋转木马移动到下方之后有一个回调选项,但无法解决如何设置它以便每次旋转木马移动时更新--current
并移除--current
来自上一个项目。
下面的Flipster选项:
onItemSwitch: false
// [function]
// Callback function when items are switched
// Arguments received: [currentItem, previousItem]
非常感谢任何人解决此问题的时间。
我也尝试过以下代码:
// the flipster element on your page
$("#coverflow").flipster({
onItemSwitch: myHandler
//Arguments received: [currentItem, previousItem]
});
//your handler
function myHandler(currentItem, previousItem) {
$(previousItem).removeClass("flipster__item--current");
$(currentItem).click(function(){
alert('Testing!');
});
}
答案 0 :(得分:0)
你走在正确的轨道上。添加处理程序。您可以使用jquery $(current)
$(function () {
// the flipster element on your page
$("#coverflow").flipster({
style : 'carousel',
onItemSwitch : myHandler
//Arguments received: [currentItem, previousItem]
});
//your handler
function myHandler(current, prev) {
alert('Testing!');
}
})