#14840 closed bug (notabug)
$(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.
Change History (3)
comment:1 Changed 9 years ago by
comment:2 follow-up: 3 Changed 9 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
The documentation on .data()
says that it gets the data-
attributes once on first access.
comment:3 Changed 9 years ago by
Replying to dmethvin:
The documentation on
.data()
says that it gets thedata-
attributes once on first access.
thanks
Note: See
TracTickets for help on using
tickets.
sorry,i get wrong test case.
$(elem).attr get the right value, $(elem).data get the different value