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"
?
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"
?
3 Answers
Reset to default 5Simply use .attr
instead ($element.attr('data-item-id');
). The docs themselves suggest this.
Try this:
$element.attr("data-item-id")
Using attr
: http://jsbin./ipuhah/
$(selector).attr("data-item-id");