Learn all about the jQuery function jQuery.data().
Note: This is a low-level method; a more convenient
.data() is also available.
jQuery.data() method allows us to attach data of any type to DOM elements in a way that is safe from circular references and therefore free from memory leaks. jQuery ensures that the data is removed when DOM elements are removed via jQuery methods, and when the user leaves the page. We can set several distinct values for a single element and retrieve them later: