An element's attributes can contain useful information for your application, so it's important to be able to get and set them.
link The .attr()
method
The .attr()
method acts as both a getter and a setter. As a setter, .attr()
can accept either a key and a value, or an object containing one or more key/value pairs.
.attr()
as a setter:
1
2
3
4
5
6
|
|
.attr()
as a getter:
1
|
|