如何停止幻灯片放映

时间:2011-11-24 15:59:03

标签: jquery jquery-plugins

我正在为我们的一个项目使用jbgallery幻灯片(http://maxb.net/scripts/jbgallery/)。

如果用户点击了prev& amp;下一个按钮。我们有一个自动幻灯片放映,但当用户点击任一按钮时,自动滑动应停止。

1 个答案:

答案 0 :(得分:2)

开发人员似乎没有为他的按钮编码任何真正的回调。使用Firebug for Firefox(或其他DOM检查器),您可以获取其元素的类名,并通过这样的信息完成您想要的内容。

var obj = $("#jbgallery-api").jbgallery({
    menu: "slider",
    slideshow: "true"
}, true);  // true parameter = return jbgallery object (for use to stop later)

// .jbgs-h-prev = prev button class, .jbgs-h-next = next button class
$('.jbgs-h-prev, .jbgs-h-next').click(function() {  // onClick event handler
    obj.stop();  // Stop the slideshow

    // Using obj.stop() doesn't reset the state of the play/pause button
    // so we need to hide the pause button and show the play button.
    $('.jbgs-h-pause').hide();
    $('.jbgs-h-play').show();
});

小提琴演示:http://jsfiddle.net/5sXDS/

相关问题