JQuery: differences between attr () and prop ()
Attr ()
Get 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.
Obtains the attribute of the first element in the matched element set, or adds up to one attribute to each selected element.
Prop ()
Get the value of a property for the first element in the set of matched elements or set one or more properties for every matched element.
Obtains the property of the first element in the matched element set, or adds up to one property for each selected element.
It can be observed that the functions of the two are very similar, but the objects of the two operations are different.
In this way, the problem is reduced to the difference between attribute and property.
Attribute and propery both have the meaning of attributes. to distinguish them, we agree to name attribute as an attribute and property as a feature.
Attribute
In javascript, getAttribute () is used to obtain the node attribute values.
Node attribute value. We mean the value of src in