.prop() vs .attr() in jquery

The .prop() method should be used for boolean attributes/properties and for properties which do not exist in html (such as window.location). All other attributes (ones you can see in the html) can and should continue to be manipulated with the .attr() method.

Below is a list of some attributes and properties and which method should normally be used when getting or setting them. This is the preferred usage, but the .attr() method will work in all cases.

Attribute/Property.attr().prop()
accesskey

Yes

 
align

Yes

 
async

Yes

Yes

autofocus

Yes

Yes

checked

Yes

Yes

class

Yes

 
contenteditable

Yes

 
draggable

Yes

 
href

Yes

 
id

Yes

 
label

Yes

 
location ( i.e. window.location )

Yes

Yes

multiple

Yes

Yes

readOnly

Yes

Yes

rel

Yes

 
selected

Yes

Yes

src

Yes

 
tabindex

Yes

 
title

Yes

 
type

Yes

 
width ( if needed over .width() )

Yes

 

Reference Url: http://blog.jquery.com/2011/05/10/jquery-1-6-1-rc-1-released/