KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Something that's been bugging me recently is the use of HTML5 data attributes and when is the appropriate to use them. Typically, on a page that performs a number of AJAX calls to my server, I require the ID that is representative of the page being viewed. I've currently been storing this in a hidden <input> element on the page, which is then accessed and stored in a JS variable at the top of my jQuery doc ready call. I've been considering moving it to a data-id attribute on the body element, which I then would access in jQuery using $('body').data('id'); . Is there any advantages to using HTML5 data atttributes or visa versa? Performance? Security? "Best-Practices"? It's my understanding that data attributes are accessible by all browsers so dealing with IE isn't a concern.
Tags (comma-separated)
Save Edits
Cancel