单击链接时jquery循环停止循环

时间:2012-08-22 14:28:30

标签: jquery cycle jquery-cycle

我有一个jquery循环,有三个横幅和3个横幅链接。

<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 乌兹

1 个答案:

答案 0 :(得分:0)

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

$('#adverts').cycle('stop')
相关问题