You can use data-*
attribute to embed custom data. The data-*
attributes gives us the ability to embed custom data attributes on all HTML elements.
jQuery .data()
method allows you to get/set data of any type to DOM elements in a way that is safe from circular references and therefore from memory leaks.
jQuery .attr()
method get/set attribute value for only the first element in the matched set.
Example:
<span id="test" title="foo" data-kind="primary">foo</span>
$("#test").attr("title");
$("#test").attr("data-kind");
$("#test").data("kind");
$("#test").data("value", "bar");