Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
68
Help us understand the problem. What is going on with this article?
@Vit-Symty

jQueryでfadeOutの後にremove

More than 5 years have passed since last update.

要素をフェードアウトした後に削除しようと、

sample.js
$(this).fadeOut('fast').remove();

としてみたところ、
フェードアウトせずにそのまま消えてしまった。

ちょっと調べてみると、処理を待つキューに入る処理と入らない処理があるとのこと。
エフェクト系は概ね入るようだけど、remove()はキューに入らない。
キューに入れるには.queue()を使う。

sample.js
$(this).fadeOut('fast').queue(function() {
  this.remove();
});

これでフェードアウトを待って削除できる。

68
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Vit-Symty
スーパー牛さんパワーなどはありません。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
68
Help us understand the problem. What is going on with this article?