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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:19:54+00:00 2026-06-01T08:19:54+00:00

I am assigning some data to html objects by a jquery I’m creating, the

  • 0

I am assigning some data to html objects by a jquery I’m creating, the thing is that when I call a method from the plugin, the data I have assigned is not in the object anymore.

  • 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-01T08:19:56+00:00Added an answer on June 1, 2026 at 8:19 am

    It’s useful to understand how .data() works to understand how long the data lives. When you store something with .data(), it goes into an internal javascript data structure in jQuery. So, in that respect, it’s just a javsacript variable and it lives for as long as any other javascript variable lives.

    That means once you leave the page, it’s entirely gone – just like all other javascript variables.

    The other way the data can be removed is if some javascript code specifically removed the data from the data structure. That will normally only happen if you use a jQuery method that intentionally disposes of a DOM object. That can be done with $(elem).remove() or with $(elem).html("some html) and any other jQuery methods that remove elements from the DOM. Since those methods remove objects from the DOM, jQuery “cleans up” the .data() information associated with those elements. The one specific exception to this is .detach() which removes an element from the DOM, but does not remove it’s .data() info. This is done on purpose to allow you to remove it from the DOM, but preserve it’s state presumably so you can put it back in the DOM somewhere else or some time later.

    Note: if you remove a DOM element from the DOM without using jQuery functions (such as .removeChild() or by assigning to .innerHTML), jQuery will not know that you’ve removed those DOM elements and the .data() info will not be cleaned up – it will essentially just be wasting space in memory. It doesn’t cause any harm other than consuming some extra memory. If that .data() info contains references to other javascript or DOM elements, it could cause even larger memory leaks.

    If you are using .data() it creates one case where you want to stick with jQuery methods for anything that can cause DOM elements to be removed. Normally with jQuery, you are free to mix/match plain javascript and jQuery, but this is one case where you shouldn’t.

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

Sidebar

Related Questions

I have a repeater which fetches data from a database and shows some labels
Im sending over some json data and assigning to a hidden field using: @Html.Hidden(hidden-places,
I have some data in string format that represents binary data (e.g. '0x0002'). Is
Need some help assigning a mouseover event to display some icons that start out
I have a FOR XML PATH Stored Procedure that returns some XML in the
Updated I have some huge data, which becomes a large table say table parent
I was trying to read data from some huge file and write them back,
Let's say I want to pass some extra data when assigning an event handler.
I have a callback procedure: type TInitCallback = procedure (var Data: Pointer); The idea
A quote from MSDN Assigning an instance of this type is not thread safe

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.