#13623 closed bug (duplicate)
jQuery.data() does not work when using an attribute selector
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 2.0b2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
It's my understanding that .data should get/set "data-" attributes.
However, after using .data("foo", "value") to set a particular attribute on an element, that element is not selectable using a "[data-foo=value]" selector. Using .attr instead works as expected.
jsFiddle: http://jsfiddle.net/AsJDb/1/
I'm pretty sure this exists downlevel as well.
Change History (3)
comment:1 Changed 10 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:2 Changed 9 years ago by
This bug is not a duplicate of #13234.
The jsfiddle provided in the bugreport clearly demonstrates the problem. I created a different one that exposes the same bug: http://jsfiddle.net/MG44D/
Please reopen this bug.
comment:3 Changed 9 years ago by
As documented, the jQuery .data()
API does not set data-
attributes.
The data- attributes are pulled in the first time the data property is accessed and then are no longer accessed or mutated (all data values are then stored internally in jQuery). -- http://api.jquery.com/data/
Duplicate of #13234.