2

いくつかのdivをfadeOutにしてから、削除しようとしています。

$("article.articles .thumb a").click(function() {
    $(this).parent().parent().addClass("selected");
    $("article.post").not(".selected").fadeOut(500).delay(1500).remove();
    $('#stream').isotope('reLayout');
});

ただし、divはフェードせずにすぐに削除されます。

私は何が間違っているのですか?

4

3 に答える 3

1

fadeOut()フェード効果が完了した後に実行されるコールバック関数を使用できます。

.fadeOut([duration] [、callback])

$("article.post").not(".selected").fadeOut(500, function(){
   $(this).remove();
})

また:

$("article.post").not(".selected").fadeOut(500).delay(2000).queue(function(){
   $(this).remove()
})
于 2012-07-14T01:12:01.743 に答える
0
$("article.articles .thumb a").click(function() {
    $(this).parent().parent().addClass("selected");
    $("article.post").not(".selected").fadeOut(500, function(){
    setTimeout(function(item){ 
      jQuery(item).remove(); }, 1500, $(this));
});
    $('#stream').isotope('reLayout');
});
于 2012-07-14T01:12:22.700 に答える
0

divがフェードアウトするのを待ってから削除します。コールバック関数を作成し、その中でremoveを呼び出す必要があります。

このスニペットを使用してください-

   $("article.post").not(".selected").fadeOut(500, function(){
                            $("article.post").not(".selected").remove();
                        });
于 2012-07-14T01:14:46.010 に答える