JQuery设置间隔和点击功能困境

时间:2011-09-05 16:55:41

标签: jquery timeout intervals next

以下脚本会每隔5000毫秒或点击一次触发更改图像。

用户.next()计算下一个缩略图,以便在自动超时时单击。问题是,当用户点击缩略图时,自动功能在5000ms后正确启动,但是下一个()没有根据用户点击更新,显示的图像不是下一个图像,而是下一个图像如果用户没有点击。

var slideShowTO;
     $('#coursepanel .thumbstrip img').click(function(){
         $('#coursepanel .thumbstrip img').removeClass('active')
         $(this).addClass('active');
         var img = '#P' + $(this).attr('id');

         $('#coursepanel .gallery .feature img').removeClass('focus');
         $(img).addClass('focus');
          window.clearInterval(slideShowTO);
            slideShowTO = window.setInterval(function(){

        if($(this).attr('id') == $('#coursepanel .thumbstrip img:last').attr('id'))
        {
            $('#coursepanel .thumbstrip img:first').click();
        }
        else {
        $(this).next().click();
        }
    },5000);

有什么想法吗?

非凡

NB#我之前已经问过这个问题,但由于某种原因,之前的答案不适用于我们现在的非常相似的脚本。

1 个答案:

答案 0 :(得分:0)

似乎我还留下了另一个脚本,它优先于这个脚本。