我真的不知道如何为这个 JS 函数创建时间循环..
这是该函数: enter link description here
我需要的是每 20 秒一个时间循环进行随机排序..
我使用 - var ... = setInterval(..., 20000);
并且 - var ... = setTimeOut(...,20000);
但我不知道在哪里连接,或者是否有人知道更好的方法如何做到这一点,一切都会帮助我......
非常感谢您的帮助..
最佳答案
您的尝试遇到了一些问题,下面的内容将执行您想要的操作,只需根据需要调整计时器即可
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/