Royi Namir
Royi Namir

Reputation: 148524

Are Jquery's prop and attr supposed to behave differently?

http://jsbin.com/uremuc/2/edit

If I'm choosing jquery 1.5.2 in jsBin ,

running .attr('tagName') should return me undefined ( or something else but not the real result) since its not suppose to read the dom element as Prop does.

So why is it working ? It doesnt suppose to be working...

Upvotes: 0

Views: 89

Answers (1)

dnuttle
dnuttle

Reputation: 3830

For example, selectedIndex, tagName, nodeName, nodeType, ownerDocument, defaultChecked, and defaultSelected should be retrieved and set with the .prop() method. Prior to jQuery 1.6, these properties were retrievable with the .attr() method, but this was not within the scope of attr. These do not have corresponding attributes and are only properties.

From jquery.com's .prop() page

Upvotes: 3

Related Questions