Side navigation
#10042 closed bug (invalid)
Opened August 13, 2011 09:03AM UTC
Closed August 13, 2011 08:52PM UTC
Last modified August 22, 2011 01:18PM UTC
data() and attr()
Reported by: | ziguan.lin@gmail.com | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | data | Version: | 1.6.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
cores like this:
<div id="test" data-userid='0000000123'></div>
$("test").data('userid') ==> 123
$("test").attr('data-userid') ==> 0000000123
Attachments (0)
Change History (3)
Changed August 13, 2011 06:07PM UTC by comment:1
Changed August 13, 2011 08:52PM UTC by comment:2
component: | unfiled → data |
---|---|
priority: | undecided → low |
resolution: | → invalid |
status: | new → closed |
Yes, this is actually a feature and is described in the docs:
"Every attempt is made to convert the string to a JavaScript value (this includes booleans, numbers, objects, arrays, and null) otherwise it is left as a string. To retrieve the value's attribute as a string without any attempt to convert it, use the attr() method."
there is an error...selector is wrong...
$("test") you mean $("#test") maybe... ;)