jQuery attr vs prop?

Unfortunately none of your links work 🙁 Some insight though, attr is for all attributes. prop is for properties. In older jQuery versions (<1.6), we just had attr. To get to DOM properties such as nodeName, selectedIndex, or defaultValue you had to do something like: var elem = $(“#foo”)[0]; if ( elem ) { index … Read more

difference between prop() and attr() in jQuery and when to use attr() and prop() [duplicate]

from docs The difference between attributes and properties can be important in specific situations. Before jQuery 1.6, the .attr() method sometimes took property values into account when retrieving some attributes, which could cause inconsistent behavior. As of jQuery 1.6, the .prop() method provides a way to explicitly retrieve property values, while .attr() retrieves attributes. example … Read more

.prop() vs .attr()

Update 1 November 2012 My original answer applies specifically to jQuery 1.6. My advice remains the same but jQuery 1.6.1 changed things slightly: in the face of the predicted pile of broken websites, the jQuery team reverted attr() to something close to (but not exactly the same as) its old behaviour for Boolean attributes. John … Read more