【问题标题】:JQuery set interval and click function dilemmaJQuery设置间隔和点击功能困境
【发布时间】:2011-09-05 16:55:40
【问题描述】:

以下脚本每 5000 毫秒或点击时触发更改图像。

它用户 .next() 在自动超时时计算出下一个要单击的缩略图。问题是当用户点击缩略图时,自动功能会在 5000 毫秒后正确启动,但 next() 不会根据用户点击进行更新,并且显示的图像不是下一张,而是下一张如果用户没有点击。

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#我以前问过这个问题,但由于某种原因,以前的答案不能使用我们现在拥有的非常相似的脚本。

【问题讨论】:

    标签: jquery timeout intervals next


    【解决方案1】:

    看来我还留下了另一个优先于这个的脚本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-07
      • 2014-07-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多