在JQuery中使队列函数无休止地循环 [英] Making a never-ending loop of queued functions in JQuery

查看:77
本文介绍了在JQuery中使队列函数无休止地循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的一个网页中运行着一个javascript脚本.在此脚本中,我有8个函数依次运行.

我的问题是,是否有一种方法可以循环此功能队列,从而使其以首次运行的顺序连续运行?

任何回复都非常感谢,
Tom.

Hi everyone,

I have a javascript script running in one of my webpages. In this script I have 8 functions running one after another, in order.

My question is, is there a way of looping this queue of functions, so that is constantly runs, in the same order that it first runs?

Any replies are most appreciated,
Tom.

推荐答案

为什么不在当前"函数的最后一行代码中调用下一个函数?

Why don''t you call the next function on the last line of code in the ''current'' function?

var myFunctions = {
    one: function(){
        myFunctions.two();
    },
    two: function(){
        myFunctions.three();
    },
    three: function(){
        myFunctions.four();
    },
    four: function(){
        myFunctions.one();
    }
}


(document).ready(function(){ myFunctions.one(); });
(document).ready(function(){ myFunctions.one(); });



但是,当然,它具有八个功能而不是四个功能.

祝你好运!



But than ofcourse with eight functions in stead of four.

Good luck!




此处 [ ^ ]是对爱德华答案的贡献...

另一个解决方案是对函数进行数组处理,并使用jquery each 和setTimeout逐个调用它们...


Here[^] is a contribution to Eduard''s answer...

Another solution is to make an array of your functions and the use jquery each and setTimeout to call them one by one...


这篇关于在JQuery中使队列函数无休止地循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆