2012-02-27 52 views

回答

1

由於您使用jQuery移動已經走了,

.delay() 

從jQuery的。 http://api.jquery.com/delay/

還有一個這樣的another question。請注意,jQuery文檔聲明瞭這一點 -

.delay()方法最適合延遲排隊的jQuery 效果。因爲它是有限的 - 例如,它不提供一種方式來取消延遲 - .delay()不是替代JavaScript的原生 setTimeout函數,這可能更適合某些使用 的情況。

這裏是jQuery的文檔

<!DOCTYPE html> 
<html> 
<head> 
    <style> 
div { position: absolute; width: 60px; height: 60px; float: left; } 
.first { background-color: #3f3; left: 0;} 
.second { background-color: #33f; left: 80px;} 
</style> 
    <script src="http://code.jquery.com/jquery-latest.js"></script> 
</head> 
<body> 

<p><button>Run</button></p> 
<div class="first"></div> 
<div class="second"></div> 

<script> 
    $("button").click(function() { 
     $("div.first").slideUp(300).delay(800).fadeIn(400); 
     $("div.second").slideUp(300).fadeIn(400); 
    }); 
</script> 

</body> 
</html> 
+0

爲例,如果以下項目使用效果隊列這隻會工作。 – rockerest 2012-02-27 14:22:02

0
function loadStuff() 
{ 
    //load stuff 
} 

setTimeout(function(){loadStuff()}, 5000); 

編寫你的函數來做你的加載,然後在超時5秒後調用該函數。

0

使用javascript setTimeout()函數。例如setTimeout(「function()」,5000);