Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery data() get incorrect number data

I user jQuery 1.6.1 and browse is Chrome 11

I put some data in DIV, like this:

<div id="user" data-user-id="68029454802354176"></div>

and try to use .data() to fetch the userId

console.log($('#user').data('userId'));

I must get 68029454802354176, but it just return 68029454802354180

Why does it change my number?

like image 457
Hank Wang Avatar asked May 20 '11 04:05

Hank Wang


1 Answers

i dont think this has any thing to do with jquery more how javascript handels big numbers

its to bad data returns a number and not a string in this case

  $("#user").attr("data-user-id")

will get you a correct string at lest

if you put 68029454802354176 in the chrome console it gives you 68029454802354180 back

like image 106
megakorre Avatar answered Sep 23 '22 09:09

megakorre