As of jQuery 1.6, the .attr() method returns undefined for attributes that have not been set.
In addition, .attr() should not be used on plain objects, arrays, the window, or the document.
To retrieve and change DOM properties, use the .prop() method.