Opened 10 years ago
Closed 10 years ago
#12270 closed enhancement (duplicate)
Unify .data() with HTML5 data attribute.
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
http://api.jquery.com/data/#data-html5 "As of jQuery 1.4.3 HTML 5 data- attributes will be automatically pulled in to jQuery's data object. '
How about other way round? Enabling .data("value", "param") to be available outside of jQuery?
See the top comments by Ryan Kinal: "It would be awesome if it were the element instead, but that is not the case."
Change History (3)
comment:1 follow-up: 2 Changed 10 years ago by
comment:2 Changed 10 years ago by
Replying to scott.gonzalez:
Why not just set the
data-
attribute if that's what you want? Attributes can only store strings, while.data()
can store any type of value.
Just saying that for string-only values jQuery can serve two way compatibility.
Posted as an "enhancement" for a discussion.
comment:3 Changed 10 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Reading is cheap, writing is not. data()
precedes "data-*" and has semantics of its own to consider. Also this is probably a duplicate, but I can't find the original.
Why not just set the
data-
attribute if that's what you want? Attributes can only store strings, while.data()
can store any type of value.