Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery data() type conversion issue?

I have the following div <div data-item-id="0234"> and when I try to access the data with $element.data("itemId") jQuery converts it to int and now i get 234 instead of "0234". Is there any way i can get the actual data "0234" ?

like image 793
daniels Avatar asked Dec 20 '22 20:12

daniels


1 Answers

Simply use .attr instead ($element.attr('data-item-id');). The docs themselves suggest this.

like image 108
Explosion Pills Avatar answered Dec 23 '22 11:12

Explosion Pills