Side navigation
#14840 closed bug (notabug)
Opened March 03, 2014 12:52PM UTC
Closed March 03, 2014 03:32PM UTC
Last modified March 04, 2014 02:59AM UTC
$(elem).attr and elem.getAttribute get diffrent values
Reported by: | anonymous | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
var a = $('<div data-a="abc"></div>') a.data('a'); //abc a.attr('data-a'); //abc a[0].setAttribute('a', 'efg'); a.data('a'); //abc a[0].getAttribute('a'); //efg a.attr('data-a'); //efg
in the real word, i use a mvvm framework. The attr changes by the framework. i cant use $(elem).data() method to change the value, but i need to get the value.
Attachments (0)
Change History (3)
Changed March 03, 2014 01:16PM UTC by comment:1
Changed March 03, 2014 03:32PM UTC by comment:2
resolution: | → notabug |
---|---|
status: | new → closed |
The documentation on .data()
says that it gets the data-
attributes once on first access.
Changed March 04, 2014 02:59AM UTC by comment:3
Replying to [comment:2 dmethvin]:
The documentation on.data()
says that it gets thedata-
attributes once on first access.
thanks
sorry,i get wrong test case.
$(elem).attr get the right value, $(elem).data get the different value