Copy Code code as follows:
1.$ ("Element"). attr (name) gets the first matching property value, such as $ ("img"). attr ("src")
2.$ ("element". attr (Key,value)) ' One element set properties
3.$ ("Element". attr ({key:value,key1:value,....})) ' Set multiple attributes at once for an element
4.$ ("Element"). attr (key,function) ' Sets a calculated property value for all matching elements.
5.$ ("Element"). Removeattr (name)//Remove a property
JQuery Code:
Copy Code code as follows:
Parameter Properties Description:
Set SRC and ALT attributes for all images.
JQuery Code:
Copy Code code as follows:
$ ("img"). attr ({src: "test.jpg", alt: "Test Image"});
Parameter Key,value Description:
Set the SRC attribute for all images.
JQuery Code:
Copy Code code as follows:
$ ("img"). attr ("src", "test.jpg");
Parameter key, description of the callback function:
Sets the value of the SRC attribute to the value of the title property.
JQuery Code:
Copy Code code as follows:
$ ("img"). attr ("title", function () {return this.src});
The above is the entire content of this article, are a number of personal experience Summary, I hope you can enjoy.