CLOSE FULL VIEW
Deep Dive into HTML5 and CSS3
Recorded at:
Community comments
jQuery Custom Data Attributes
by
David Clarke
Posted
jQuery Custom Data Attributes
by
David Clarke
Thanks for the presentation Wes. I just wanted to point out that jQuery supports custom data attributes in a more direct way. Instead of $("someSelector").attr("data-my-data"), using jQuery you can use $("someSelector").data("my-data"); which will automatically add the "data-" prefix. Also worth noting is a breaking change in jQuery 1.6 which uses camel case for accessing data attributes. Quoting the jQuery api documentation, "The treatment of attributes with embedded dashes was changed in jQuery 1.6 to conform to the W3C HTML5 specification."




Hello stranger!
You need to Register an InfoQ account or Login to post comments. But there's so much more behind being registered.Get the most out of the InfoQ experience.
Tell us what you think