我在jQuery/Javascript中編程有點新,並且在div標記(容器)中顯示/隱藏了一系列標題時出現了一些問題。企圖回調腳本代碼是:jQuery回調函數問題
$(document).ready(function(){
$('<h1>Text1</h1>').hide().prependTo("#container").fadeIn(2000, function(){
$("#container h1").fadeOut(2000, function(){
$('<h1>Text2</h1>').hide().prependTo("#container").fadeIn(2000, function(){
$("#container h1").fadeOut(2000, function(){
$('<h1>Text3</h1>').hide().prependTo("#container").fadeIn(2000, function(){
$("#container h1").fadeOut(2000, function(){
$('<h1>Text4</h1>').hide().prependTo("#container").fadeIn(2000);
});
});
});
});
});
});
});
我基本上希望它dislay Tesxt1頭有淡入,淡出,然後,然後用淡入淡出和文本2 desplay。 Text4是最後一個,應該只有一個沒有淡出的淡入淡出。如果沒有回調函數,一切都會同時執行,並且當它們在上面添加(錯誤地)時,以後的文本會被多次前置。
非常感謝您的時間。
<<<<<<<<<<<> >>>>>>>>>> :-)你正在編寫代碼或做一些ASCII藝術嗎? –
不好意思,上面的粗體只是帶有<>的標題標籤h1 Text1/h1,依此類推。 – Jeremy
我正在編寫代碼,並且沒有回調的原始代碼是:$('
Text1
').hide()。prependTo(「#container」)。fadeIn(2000); $(「#container h1」)。fadeOut(2000); ();();('Text2
').hide()。prependTo(「#container」)。fadeIn(2000); $(「#container h1」)。fadeOut(2000); ();();('Text3
').hide()。prependTo(「#container」)。fadeIn(2000); $(「#container h1」)。fadeOut(2000); ();();('Text4
').hide()。prependTo(「#container」)。fadeIn(2000); – Jeremy