I just met some very disturbing behavior in jQuery 1.6.2, which I hope someone can explain. Given the following markup ...
<div id="test" data-test=" 01">Test</div>
Can someone tell me why accessing an attribute through .data()causes it to deal with int?
var t = $("#test").data("test");
alert(t); // shows "1"
t = $("#test").attr("data-test");
alert(t); // shows " 01"
Of course, I have proof in jsFiddle of this behavior.
source
share