The html object:
<div data-myAttribute="test"></div>
The code:
var $o = $("div");
$.each($o.data(),function(k,v){
console.log(k);
//writes 'myattribute' instead of 'myAttribute'
});
How do I preserve the case of the attribute?
data-my-attribute
to get.data('myAttribute')
– Caesalpiniaceousdata-my-attribute
is perfectly valid attribute name regarding spec:For each name on the list, for each U+002D HYPHEN-MINUS character (-) in the name that is followed by a character in the range U+0061 to U+007A (U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER Z), remove the U+002D HYPHEN-MINUS character (-) and replace the character that followed it by the same character converted to ASCII uppercase.
– Caesalpiniaceous