setInterval()中的函数无延迟地执行 [英] function in setInterval() executes without delay
问题描述
我正在制作一个jquery应用程序,通过使用setInterval()在指定的时间间隔后隐藏图像。问题是隐藏图像功能立即执行而没有延迟。
I am in the process of making a jquery application to hide an image after a specified interval of time by using setInterval(). The problem is that the hide image function executes immediately without delay.
$(document).ready(function() {
setInterval(change(), 99999999);
function change() {
$('#slideshow img').eq(0).removeClass('show');
}
});
我在 jsfiddle 。
推荐答案
你立即调用了这个函数而不是将其传递给 setInterval
。
You called the function immediately instead of passing it to setInterval
.
setInterval(change,1500)
- 将函数更改
更改为 setInterval
setInterval( change, 1500 )
- passes function change
to setInterval
setInterval(change(),1500)
- 调用函数更改
并传递结果( undefined
)到 setInterval
setInterval( change(), 1500 )
- calls the function change
and passes the result (undefined
) to setInterval
这篇关于setInterval()中的函数无延迟地执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!