Assuming you are using jQuery
data-* attributes are pulled into that object. For more information check the docs.
To save the data as HTML data attributes use
.attr(). Something like the following: