I want to save a reference to a specific object reflecting properties for the current dom element for some elements of the dom tree. Each element could have a different reference to another object or they could reference the same. Is it possible to use html5’s data property therefore or is there another way to do that in plain javascript (not jquery).
Thanks for help!
If you’re simply looking to store static properties, then you can use the
setAttributemethod on each dom element, like soBut if you’re looking at things that aren’t JSON encodable ( or rather cannot be represented as strings ), then you’ll have to look at other ways.
The jQuery data method doesn’t actually store anything on the dom element itself. It maintains an internal cache with all the data that is passed to it.