Using jQuery’s Data APIs
learningjquery.com
learningjquery.com
I'm not sure why anyone would want to use an attribute for storage, but this is good info. I for one love data-* attributes. It's better than the days of trying to pack info into the id or rel attributes.
Is there some reason not to do that besides 'it would fail a validator test'?
...I hear that a bit when this question comes up. Personally, I think the site would be due for an update by then anyway.
TLDR: Only use HTML5 data-* attributes server side. Just use .data() to manipulate data in the client.
This is the first place I have seen this behavior documented. Luckily, I have not ran into problems because of the weird behavior, but this could clearly cause a developer some confusion.
The reason I wrote the post was because people see the `.data()` API in jQuery, which existed before HTML5, and think it has something to do with `data-` attributes. Indeed, we made it import them, but there isn't a good reason to keep them "in sync" -- and many reasons not to do that.
I think all of behavior has been documented for some time, it's just spread across two or three different pages at http://api.jquery.com. Also, the blog post is emphasized to draw the attention of people who are trying to misuse it to manipulate HTML5 `data-` attributes.
I can see benefit of using 'data-*' attributes though.