2009-02-11 82 views
2

我在創建一個DOM元素時遇到了問題,將它附加到另一個元素並使其淡入到位。即時創建一個DOM元素,但在淡入淡出

這似乎並不工作:

$('<div/>').html('hello').appendTo('#parentDiv').fadeIn(); 

有人把我在正確的軌道上

回答

6

嘗試:

$("<div>hello</div>").hide().appendTo("#parentDiv").fadeIn(); 

或者可選地設置顯示y沒有,而是隱藏()。

+0

該死的! John讓jQuery變得簡單。我應該意識到這一點。 – User 2009-02-11 15:02:37

0

你試過

$('<div/>').html('hello').appendTo('#parentDiv').hide().fadeIn();