Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7963789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:41:46+00:00 2026-06-04T05:41:46+00:00

I am attempting to remove an object from a page with jQuery. I also

  • 0

I am attempting to remove an object from a page with jQuery. I also want to animate the removal. The goal is to make the element fadeOut(), wait a second, then remove(). But it seems to refuse to wait to remove the element, even when I use it in a setTimeout() function. How can I make an element fadeOut(), and then remove() it?

$("button").click(function() {
    $(this).fadeOut();
    setTimeout(function() { $(this).remove();}, 1000);
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:41:48+00:00Added an answer on June 4, 2026 at 5:41 am

    In your timeout function, this isn’t what you think it is – it’s actually the global window object.

    In any event (no pun intended) you should use a “completion callback”:

    $("button").click(function() {
        $(this).fadeOut('slow', function() {
            $(this).remove();
        });
    });
    

    Never, ever, mix setTimeout and the animation queue. It’s fine to interleave the two, i.e having a completion callback start a timer, or having a timer starting an animation, but it’s never OK to assume that you can start both a 1000ms animation and a 1000ms timer and have them complete at the same time.

    EDIT fixed code – no need for self in a completion callback, I was still thinking about setTimeout and this when I wrote that!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am encountering an issue when attempting to remove an object from my Core
I'm attempting to remove a character from a string in C. The problem I
I'm an R newbie and am attempting to remove duplicate columns from a largish
I am attempting to create a COM object from a remote source in Coldfusion
Greetings, I am attempting to remove multiple documents from a MongoDB collection using the
am having some trouble with attempting to remove a memory leak from my code.
So I'm attempting to remove specific parameters from the URL query string that are
Im attempting to remove double quotes passed in a request parameter string. I know
I am attempting to remove dynamically created controls in C# 2008 asp.net The controls
Possible Duplicate: Concurrent Modification Exception : adding to an ArrayList I'm attempting to remove

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.