【问题标题】:jquery cycle stop cycle when clicked on link单击链接时jquery循环停止循环
【发布时间】:2012-08-22 22:47:53
【问题描述】:

我有一个带有三个横幅和三个横幅链接的 jquery 循环。

<div id="adverts" style="position: relative; width: 960px; height: 246px; ">
   <img class="im" src="/uploads/ssp/album_2/image_59.jpg" alt="open" data-id="http://co.uk/content/2/207/eis-fund-3.html" height="246" width="960" style="position: absolute; top: 0px; left: 0px; display: block; z-index: 4; opacity: 1; width: 960px; height: 246px; ">    
    <img class="im" src="/uploads/ssp/album_2/image_60.jpg" alt="extended" data-id="" height="246" width="960" style="position: absolute; top: 0px; left: 0px; display: none; z-index: 3; opacity: 0; width: 960px; height: 246px; ">
    <img class="im" src="/uploads/ssp/album_2/image_61.jpg" alt="Welcome" data-id="" height="246" width="960" style="position: absolute; top: 0px; left: 0px; display: none; z-index: 3; opacity: 0; width: 960px; height: 246px; ">
</div>

<ul id="nav">   
<li class=""><a href="#">open</a></li>
<li class=""><a href="#">extended</a></li>
<li class="activeSlide"><a href="#">Welcome</a></li></ul>

$(document).ready(function () {

    $('#adverts').cycle({
        fx: 'fade',
        pager: '#nav',
        speed: 300,
        // callback fn that creates a thumbnail to use as pager anchor 
        pagerAnchorBuilder: function (idx, slide) {
            return '<li><a href="#">' + slide.alt + '</a></li>';
        }
    });

    $(".im").click(function () {
        var url = $(this).attr('data-id');
        window.location = url;
    });

});

当前,当您单击链接时,它会转到正确的横幅。但是,我希望它停止循环并仅在用户单击另一个横幅时才更改,或者在单击发生后将每 3 秒更改一次的速度提高到 10 次?

Rgds 乌兹

【问题讨论】:

    标签: jquery cycle jquery-cycle


    【解决方案1】:

    您可能需要查看stoppause 命令:http://jquery.malsup.com/cycle/options.html

    $('#adverts').cycle('stop')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-18
      • 1970-01-01
      • 1970-01-01
      • 2022-11-28
      • 1970-01-01
      相关资源
      最近更新 更多