I have been trying to figure this out for 2 days and could not make any sense.
I use jquery to select the first element from the page and get it’s id using:
$('#main li.twitter').eq(0);
The console log outputs:
[li class=”twitter event left” id=”131325521001848832″ style=”display: list-item; “>… li]
However:
var id = parseInt($('#main li.twitter').eq(0).attr('id'));
Outputs
131325521001848830
Not what I would expect! And if I try to select the element with that id it return an empty array so it doesn’t even exist.What am i doing wrong here ?
Numeric ids are valid in HTML5 and you can get away with it in previous versions. However, the number is so large it cannot be accurately represented in the floating point representation JS uses.
Typing the number into the console
outputs:
So you are better off keeping it as a string.