The jQuery function .attr()
, gets the value of an attribute for the first element in the set of matched elements or set one or more attributes for every matched element.
It is worth noting that when getting the value of an attribute, it only gets it from the first element that matches the selector (i.e. $("input").attr("type");
would only get the type of the first input, if there are more than one)
However, when setting an attribute, it will apply it to all matching elements.