【发布时间】:2015-06-23 08:24:21
【问题描述】:
所以,基本上我有三个函数,我希望它们一个接一个地运行,延迟两秒。
我想达到这样的目标:
firstFunction();
// Two seconds delay
secondFunction();
// Two seconds delay
thirdFunction();
// Two seconds delay
firstFunction();
等等。我尝试了 setInterval、setTimeout、jquery 延迟,到目前为止我什么也没做——在最好的情况下,所有三个函数同时运行。准确的说,这三个函数的代码非常相似
var active = $(".active.two").removeClass('active');
if (active.next('img') && active.next('img').length) {
active .next('img').addClass('active');
} else {
active.siblings(":first-child").addClass('active');
}
如果你能告诉我正确的方向,我将不胜感激。
【问题讨论】:
-
重复link
-
To be exact, code of these three functions are fairly similar>> 听起来确实像 XY 问题,您最好发布有关您预期行为的问题,而不是解决方法你认为会适合它。如果您只想在一个循环中将active类设置为不同的元素,然后发布相关的 HTML 标记本身
标签: jquery function timeout delay intervals