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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:38:29+00:00 2026-05-23T19:38:29+00:00

It looks like in jQuery after the element is destroyed, all jQuery-related data is

  • 0

It looks like in jQuery after the element is destroyed, all jQuery-related data is being destroyed – including values saved with data(), all event handlers etc. However, the dom itself is preserved and can be used again. I wonder whether it is possible to retrieve this data in any easy way, or do I have to save it myself somehow and recreate it?

Simple example written in jquery: http://jsbin.com/examuh/2/edit . You can see the effect at http://jsbin.com/examuh/2 . As you can see, only the third handler works, which is added after reappending is working – even the one added after destroy, but before reappending is not working. Apparently, the DOM along with the #id is preserved.

PS: My real example is more complex, and remaking it to move the dom element to a safe place before destroying parent will be probably quite much of a hassle.

  • 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-05-23T19:38:30+00:00Added an answer on May 23, 2026 at 7:38 pm

    If you want to retain the event handlers and jquery data etc, you can use the jQuery method .detach() to remove the elements from the DOM. You can then re-insert it back into the DOM tree at a later date using the standard .append() / .prepend() etc methods.

    If you use .remove() then the jQuery data is deleted. Your example seems to demonstrate that setting the html() property of a div has a similar effect to using .remove() in jQuery on the child elements of the div.

    var keepThis = $("#toRemove").detach();
    //.. later on
    $("#insert-point").append(keepThis);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Jquery has a great language construct that looks like this: $(document).ready(function() { $(a).click(function() {
I'm using $.blockUI with jQuery to show a modal dialogue. The HTML looks like:
I have jQuery code which looks something like this on Button1 Click $('table.result_grid tbody
Looks like there is no Load event for usercontrol on the CF. I'm used
My HTML looks like this: <html> <head> <title>Test</title> <script type=text/javascript src=jQuery.js></script> <script type=text/javascript> function
I am using jQuery. I have HTML code which looks like this: <ul> <li>123</li>
I have defined my own function, like this: jQuery.fn.createSelector = function(){ var element =
It doesn't look like basic javascript but nor can I use JQuery commands like
Looks like here in StackOveflow there is a group of F# enthusiasts. I'd like
Looks like my only option is to create a mutatant child of the tree

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.