The attr() method sets or returns the specified items' attributes and values. This function returns the value of the FIRST matched element when used to return the attribute value. This method sets one or more attribute/value pairs for the collection of matched elements when used to set attribute values.
The attr() method can be used to access the attributes of an object. This can be useful when you want to make sure that you are only changing the attributes that you want to change. You can use this method in conjunction with other methods such as css() and html().
The attr() method is one of the most useful functions in jQuery. It can be used for many different purposes, including setting and retrieving attributes, adding event handlers, and more.