The jQuery data() method will give you access to the data-* attributes, BUT, it compresses the case of the attribute name. You can use this:
$('#myButton').data("x10")
Or you can use the attr() method, which saves your case:
$('#myButton').attr("data-X10")
Try using both methods here: http://jsfiddle.net/q5rbL/
Remember that these approaches are not completely equivalent. If you change the data-* attribute of an element, you must use attr() . data() will read the value first, and then continue to return the cached copy, while attr() will re-read the attribute each time.
Note that jQuery also converts hyphens to the attribute name in the case of a camel ( source - i.e. data-some-data == $(ele).data('someData') ). Both of these conversions conform to the HTML specification, which indicates that user data attributes should not contain capital letters and that hyphens will be attached to the camel in the dataset ( source ) property. The jQuery data method simply mimics / matches this standard behavior.
Documentation
Chris Baker Jun 27 '13 at 19:12 2013-06-27 19:12
source share