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 8752533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:15:17+00:00 2026-06-13T13:15:17+00:00

So, I know that when I execute .remove() on an element in the DOM,

  • 0

So, I know that when I execute .remove() on an element in the DOM, it and all its children are removed and flagged for deletion/garbage collection. Similarly, all elements’ jQuery UI widgets will fire their “destroy” methods and all entries in the .data() space will be deleted for each element. In deciding to clean out a portion of my DOM tree, what I need to know is does remove also actually trigger .off() for each element explicitly, or do I need to do that myself?

For instance, say I have the series of divs as so:

<div id="A-1">
    <div class="HasEventListener DelegatedEventBindPoint id="B-1">
        <button class="CreatesDelegatedEvent" id="C-1" />
    </div>
    <button class="HasEventListener NonDelegatedEvent" id="B-2" />
</div>

So if I execute $(“#A-1”).remove(), does this effectively invoke commands similar to $(“.HasEventListener”).off()?

  • 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-13T13:15:18+00:00Added an answer on June 13, 2026 at 1:15 pm

    Yes, it unbinds all event handlers.

    In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed.

    Source.

    You can use detach() if you want to keep the event handlers.

    Also, you mention…

    So, I know that when I execute .remove() on an element in the DOM, it and all its children are removed and flagged for deletion/garbage collection.

    That isn’t necessarily true. You may still have references to those elements. Instead, the reference count will be decremented, and if it reaches 0, then it may be flagged for GC.

    jsFiddle.

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

Sidebar

Related Questions

I know that Java have its own garbage collection, but sometimes I want to
I know its generally a big No-No to modify a collection that you are
I believe that we are all know that setUp (@Before) will execute before any
How can i execute a command prompt command from ie9? I know that this:
I have a query that I need to execute that I do not know
I know I can remove the last element from a set: s.Remove(s.MaximumElement) But if
Is it possible to clear all resources in PHP? I know that you can
I know that Phonegap has an event for back button, but it's only available
I know that this sort of question has been asked here before, but still
I know that if port 443 is open that means the remote host supports

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.