Skip to main content

Bug Tracker

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: Owned by:
Priority: low Milestone: None
Component: data Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:

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 anonymous comment:1

there is an error...selector is wrong...

$("test") you mean $("#test") maybe... ;)

Changed August 13, 2011 08:52PM UTC by timmywil comment:2

component: unfileddata
priority: undecidedlow
resolution: → invalid
status: newclosed

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."

Changed August 22, 2011 01:18PM UTC by timmywil comment:3

#10106 is a duplicate of this ticket.