Is there a way to stop the .data() function from converting the data to another type?
For example, with the HTML <div data-code-name="007">Bond, James</div>
$("div").data("codeName") returns 7 instead of “007”
Example: http://jsfiddle.net/dMHS4/
Update: I just noticed in the fiddle that if you change to jQuery 1.8.2 it does not convert. http://jsfiddle.net/dMHS4/2/
Update: Has jQuery 1.8 changed how .data() returns the value?
Use
.attr()instead of.data():http://jsfiddle.net/dMHS4/1/
Taken from the jQuery documentation: