Opened 10 years ago
Closed 10 years ago
#14385 closed bug (notabug)
The data() method returns String values for custom data-* attributes which contain Number values
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | data | Version: | 1.10.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
The data() method of jQuery returns String values for custom data-* attributes which contain Number values (containing trailing zeroes): http://jsfiddle.net/3A5tp/ (see console or html output).
Tested with the latest jQuery versions 1.x and 2.x in the most recent versions of Chrome and Firefox.
Greets
Change History (1)
comment:1 Changed 10 years ago by
Component: | unfiled → data |
---|---|
Resolution: | → notabug |
Status: | new → closed |
Note: See
TracTickets for help on using
tickets.
This is by design:
You can use
parseFloat
or numeric cast (e.g.,+( $el.data("safe") )
) to convert values yourself.