javascript - jQuery: Store additional/extra data/info inside a jQuery object? -


Is it possible to store additional data inside the jQuery object?

I now have objects that contain some data but these objects also have a visual representation of that data. It works, but I have a lot of code to keep them in sync

For example, if you remove an object from the dome, then I also have to remove the objects related to the object array. Removing is quite simple, but if I start sorting / moving the object around it then it becomes a bit more complex.

You can use it for this :)

For example:

  $ Data (element, 'varName', value); // store var value = $ .data (element, 'varName'); / /  

or use the object method:

  $ ("# ElementID"). Data ('varName', value); // store var value = $ ("# ElementID"). Data ('varName'); // get  

does not store this data on , rather it will be $. Cache stores in your console on this page), but this this [$. Expando] .

, but if you say that you remove an object, or, I'll clean it for you, you can also call it directly or to remove it.


Comments