DOM objects provide direct access to the DOM object attributes as well as the DOM element properties of the HTML elements they represent. This really is not reasonable in jQuery, because jQuery objects often represent multiple elements with varying attributes. For that reason, jQuery provides the
.prop() methods to get and set the attributes and properties of these elements.
.attr(attribute, [value]) method allows you to specify an attribute name only to get the current value as well as an optional value to set the current value. For example, the following code gets the
src value for a specific image element with
var state ...