【发布时间】:2013-05-09 20:46:44
【问题描述】:
当滚动事件发生时,我需要能够等待一定的时间。
代码:
$(window).scroll(function()
{
if($(window).scrollTop() + $(window).height() == $(document).height())
{
setTimeout(function (){}, 1000); //I need to be able to wait 1 second and then continue with execution...
$(".loader").show().delay(700).fadeOut();
$.ajax({ ///more code });
}
});
知道有什么问题吗?
为什么setTimeout() 在这个特定示例中不起作用?
【问题讨论】:
-
它工作正常。如果您希望延迟执行,您的代码编码不正确。考虑一下您正在传递一个函数。这肯定是有原因的。
-
是的,你是对的......我没有意识到这一点,它就在我面前:)
标签: javascript jquery timer scroll settimeout