【问题标题】:How to pause this Jquery slider?如何暂停这个 Jquery 滑块?
【发布时间】:2012-03-09 18:38:26
【问题描述】:

我一直在为此苦苦挣扎,这让我把头发拔掉了!

http://webdesignsalemoregon.com/westernmennoniteschool/

我在这个主页上有一个滑块,我正试图弄清楚如何向它添加“点击暂停”功能。 (也许也可以点击恢复,哈哈)

我相信这是生成滑块的代码

    var $featured_content = jQuery('#featured #slides'),
    et_featured_slider_auto = jQuery("meta[name=et_featured_slider_auto]").attr('content'),
    et_featured_auto_speed = jQuery("meta[name=et_featured_auto_speed]").attr('content');

if ($featured_content.length){
    var et_featured_options = {
        timeout: 2000,
        speed: 500,
        cleartypeNoBg: true,
        prev:   '#featured a#featured-left', 
        next:   '#featured a#featured-right',
        pager:  '#controllers',
    }
    if ( et_featured_slider_auto == 1 ) et_featured_options.timeout = et_featured_auto_speed;

    $featured_content.cycle( et_featured_options );
}

然后我添加了一个 ID="pauseButton" 的简单按钮并将其放在滑块上方。我也有这个按钮的代码

$('#pauseButton').click(function() {
$featured_content.cycle('pause');
});

但它实际上并没有暂停幻灯片?我相信它使用了来自http://jquery.malsup.com/cycle/ 的循环插件,我从http://jquery.malsup.com/cycle/pause.html 中提取了暂停代码

我哪里错了?!

【问题讨论】:

    标签: javascript jquery plugins slider cycle


    【解决方案1】:

    您的脚本正在使用jQuery.noConflict(),这会导致$ 变量恢复到包含jQuery 之前的状态。尝试将所有出现的$() 替换为jQuery()

    jQuery('#pauseButton').click(function() {
        $featured_content.cycle('pause');
    });
    

    【讨论】:

    • 哇,如果可以的话,我会给你一个大大的湿吻!你是救生员:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多