Skip to content Skip to sidebar Skip to footer

Where Does Jquery Data's Method Information Go?

Can I do
some div
where the information is a

Solution 1:

The data is stored in a variable available to the jQuery objects via closure. It is never stored in the dom. Remove method deletes the data along with the DOM element.

.remove( [ selector ] )

Similar to .empty(), the .remove() method takes elements out of the DOM. We use .remove() when we want to remove the element itself, as well as everything inside it. In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed.

source: jQuery API: remove()

Solution 2:

jQuery places a serial number on DOM elements when needed, and uses that reference to look up associated data for the element.

For example: jQuery1278101043588: 1

As long as the element exists, your data should exist. No references to the element in code are needed.

The data associated with an element is cleaned up when you call .remove() or .empty().

If you wish to remove an element from the DOM without losing the data, you can use .detach().

jQuery also has a .removeData() method for clearing data that is no longer needed. It will clear all data on the element(s) if called without passing an argument.

Post a Comment for "Where Does Jquery Data's Method Information Go?"