Hi guys, just a quick reminder that the new version of jQuery has officially been released.
There have been a number of changes and you should follow these instructions carefully before upgrading the version on your sites.
A quick what’s new
- .attr() is now .prop() – update to the Attributes module – mainly .attr() function. Your old code should still work just note some tests to focus on this update.
- Use .attr() get/set for the following: autofocus, autoplay, async, checked, controls, defer, disabled, hidden, loop, multiple, open, readonly, required, scoped, selected.
- Use .prop() get/set for the following: defaultValue, nodeName, nodeType, selectedIndex, tagName
Upgrading From 1.5.2 to 1.6.1
With the introduction of the new .prop() method and the changes to the .attr() method, jQuery 1.6 sparked a discussion about the difference between attributes and properties and how they relate to each other. It also came with some backwards compatibility issues that have been fixed in 1.6.1. When updating from 1.5.2 to 1.6.1, you should not have to change any attribute code.
Below is a description of the changes to the Attributes module in jQuery 1.6 and 1.6.1, as well as the preferred usage of the .attr() method and the .prop() method. However, as previously stated, jQuery 1.6.1 will allow you to use .attr() just as it was used before in all situations.
Note that the changes described in the 1.6 release notes regarding the .data() method have been worked around and now work seamlessly between 1.5.2 and 1.6.1.
See official jQuery 1.6.1 release notes for more info.
Sam Deering has 15+ years of programming and website development experience. He was a website consultant at Console, ABC News, Flight Centre, Sapient Nitro, and the QLD Government and runs a tech blog with over 1 million views per month. Currently, Sam is the Founder of Crypto News, Australia.