December 2013
Intermediate to advanced
384 pages
9h 54m
English
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 .attr() and .prop() methods to get and set the attributes and properties of these elements.
The .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 id="bannerImg":
var state ...
Read now
Unlock full access