What is the difference in usage between $.data and $.attr when using data-someAttribute?
My understanding is that $.data
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:
foo
$("#test").attr("title");
$("#test").attr("data-kind");
$("#test").data("kind");
$("#test").data("value", "bar");