Side navigation
#13623 closed bug (duplicate)
Opened March 19, 2013 07:33AM UTC
Closed March 19, 2013 12:40PM UTC
Last modified June 22, 2014 10:56PM UTC
jQuery.data() does not work when using an attribute selector
| Reported by: | rboxman@gmail.com | 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.
Attachments (0)
Change History (3)
Changed March 19, 2013 12:40PM UTC by comment:1
| resolution: | → duplicate | 
|---|---|
| status: | new → closed | 
Changed June 22, 2014 02:09PM UTC by comment:2
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.
Changed June 22, 2014 10:56PM UTC by comment:3
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.