I just noticed that if I try to read an html5 data-* attribute using .data it will parse automatically, whereas reading the value using .attr will not.
data-id="00123456"
- Live example here.
Why is this the default behavior? I have certain objects whose fields are of numeric values within a string, e.g. “00123456” and not 123456.
Did I miss a jQuery changelog memo or what?
Quote from the documentation:
So it seems that since jQuery 1.6 the
.datamethod parses the values.