2011-08-18 31 views
0

我想追加一個類。只有在確保元素已被完全刪除後才能出現。我該如何實現這一目標?如何在元素完全淡出後追加文本?

<html> 
<body> 
    <div id="Append"></div> 
</body> 
</html> 

$(function(){ 
$(".Appear").stop().fadeOut("fast",function(){ 
    $(this).remove(); 
    alert(123); 
    }) 

    $("#Append").append("<span class='Appear'>Appear</span>"); alert(8); 
}) 

http://jsfiddle.net/uyPJB/

+0

不是很清楚w ^你想要達到的帽子。你想不斷淡出這個元素嗎? – Sleeperson

回答

1

你可以這樣做:

var $appear = $("<span class='Appear'>Appear</span>") 
    $("#Append").append($appear) 
    $appear.fadeOut("fast",function(){$(this).remove();}); 

活生生的例子:http://jsfiddle.net/VGp2U/

2
$(".Appear").stop(true,true).fadeOut("slow",function(){ 
     $(this).remove(); 
     alert(123); 
     $("#Append").append("<span class='Appear'>Appear</span>"); 
    }); 

http://jsfiddle.net/uyPJB/4/