javascript - 真的不知道如何为这个 JS 函数创建时间循环

标签 javascript jquery

我真的不知道如何为这个 JS 函数创建时间循环..

这是该函数: enter link description here

我需要的是每 20 秒一个时间循环进行随机排序..

我使用 - var ... = setInterval(..., 20000);

并且 - var ... = setTimeOut(...,20000);

但我不知道在哪里连接,或者是否有人知道更好的方法如何做到这一点,一切都会帮助我......

非常感谢您的帮助..

最佳答案

您的尝试遇到了一些问题,下面的内容将执行您想要的操作,只需根据需要调整计时器即可

Updated CodePen

   function loop() {  // you had $(function loop(){... here, that is not right
      $container = $('#Container'); 
      if ($container.mixItUp('isLoaded')) { // check if the plugin has been initialized
        $container.mixItUp('sort', 'random', true); // if loaded, just resort
        // change true to false, to forego the animation
      } else { 

        // if not initialized, do that now
        $container.mixItUp({
          load: {
            sort: 'random'
          },
          layout: {
            containerClass: 'list',
            display: 'block'
          }
        });

      }
    }

    $(function() {  // here you had a for loop, not sure why but the int should have been var, anyway, I removed it altogether
         setInterval(loop, 2000);
    });

关于javascript - 真的不知道如何为这个 JS 函数创建时间循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33047948/

相关文章:

javascript - 如何将我的指纹设备连接到我的登录和注册脚本

javascript - 解构对象内数组内的对象

javascript - Jquery列表拖放

javascript - 使用 Alert() 显示实际的 HTML 代码

javascript - Android jQuery fadeIn 奇怪的行为

javascript - 从字符中获取 key.code?

javascript - 如何让这个portlet默认折叠起来?

javascript - 引用错误 : youtubeBgVideoStyle is not defined

javascript - 单击后如何禁用按钮

JavaScript 从站点目录预加载随机命名的图像