Learn all about the jQuery function .data().
.data() method allows us to attach data of any type to DOM elements in a way that is safe from circular references and therefore from memory leaks.
We can set several distinct values for a single element and retrieve them later:
In jQuery 1.4.3 setting an element’s data object with
.data(obj) extends the data previously stored with that element.
Prior to jQuery 1.4.3 (starting in jQuery 1.4) the
.data() method completely replaced all data, instead of just extending the data object. If you are using third-party plugins it may not be advisable to completely replace the element’s data object, since plugins may have also set data.
Due to the way browsers interact with plugins and external code, the
.data() method cannot be used on
<object> (unless it’s a Flash plugin),