开发者

Javascript or JQuery - How do I change the background color every fixed-time-interval? [duplicate]

This question already has answers here: Closed 11 years ago.

Exact Duplicate:

how can I execute javascript code every a specific time interval ?

开发者_开发知识库

Is there an efficient method for causing a javascript (ChangeDivBG(), in my case) function to execute every fixed time interval?


setInterval(ChangeDivBG, 1000); // 1000 is time interval in miliseconds - 1000ms=1sec


You can use setInterval function

setInterval(ChangeDivBG, delay);

If you want to pass an argument:

setInterval(function(color){ ChangeDivBG(color) }, delay);

If you pass an argument like this:

setInterval(ChangeDivBG, delay, color);

It won't work in IE(under IE9), be careful about that.


use setInterval (func, t).

setInterval(ChangeDivBG, 1000)

t is in milliseconds.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜