2010-02-05 17 views

回答

27
var doIt = function() { 
    $("div.my").text("My message"); 
} 
setTimeout(doIt, 3000); 
15

,如果你使用jQuery 1.4,你總是可以做:

 
$(function() { 
    $('#divId').delay(3000).text('New Text'); 
});

4

我使用下面的jQuery插件下面這個被。延遲可以用於鏈接功能,而不是現在不能。

延遲

http://plugins.jquery.com/project/delay

$('#animate-this').fadeIn().delay(500).fadeOut(); 

notNow

http://plugins.jquery.com/project/notNow

$.notNow(2000, function() { 
    alert('woolsworth'); 
}); 
+1

+1我認爲,延遲插件喲根據我的回答,您提到的實際上現在是主要jQuery庫的一部分。 – 2010-02-05 16:42:49