Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#10042 closed bug (invalid)

data() and attr()

Reported by: [email protected] 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

Change History (3)

comment:1 Changed 11 years ago by anonymous

there is an error...selector is wrong... $("test") you mean $("#test") maybe... ;)

comment:2 Changed 11 years ago by timmywil

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

comment:3 Changed 11 years ago by timmywil

#10106 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.