I have the following HTML:
<tr id="row_1" data-rk="02000008" data-pk="0001I">
When I check this with firebug it shows as:
dataset DOMStringMap { rk="02000008", pk="0001I"}
pk "0001I"
rk "02000008"
I then use jQuery to read this:
var pk = $("tr[id='row_" + row + "']").data('pk')
var rk = $("tr[id='row_" + row + "']").data('rk')
However this is what the firebug debuggers shows when I check the values in my javascript. They are also the same values that are later sent to my C# code in an Ajax call.
pk shows as "0001I"
rk shows as 2000008
Can someone explain this? Both rk and pk are coded in the same way, both have one or more leading zeros but the one returns as a string and the other as a number.
alert(typeof rk)to see if it really is a number. Attributes should always be strings, if jQuery is changing it to a number then that is a bad thing to do. From the jQuery documentation: "Every attempt is made to convert the string to a JavaScript value (this includes booleans, numbers, objects, arrays, and null) otherwise it is left as a string." So it is by design.