Like jQuery 1.4.3, the HTML data attributes will be automatically drawn into the jQuery data object. Attribute handling using inline dashes has been modified in jQuery 1.6 to meet the W3C HTML5 specification.
For example, given the following HTML:
<div data-role="page" data-last-value="43" data-hidden="true" data-options='{"name":"John"}'></div>
All of the following jQuery codes will work.
$("div").data("role") === "page";
$("div").data("lastValue") === 43;
$("div").data("hidden") === true;
$("div").data("options").name === "John";
Each attempt is made to convert a string to a JavaScript value (this includes booleans, numbers, objects, arrays, and null); otherwise, it remains as a string. To get the value attribute as a string without any attempt to convert it, use the attr () method.