jQuery's attribute operations are very simple. The following uses an a element to illustrate the attribute acquisition/setting/deletion operations
Add attributes
$('a').attr('href', 'http://www.jquery.com')
Add multiple attributes
$('a') .attr({'href':'http://www.jquery.com', 'title':'jquery.com'})
Get attributes
$('a' ).attr('href')
class attribute
addClass()
Add a class
hasClass()
Judge Whether there is a class specified in the parameter
removeClass()
Remove a class
toggleClass()
If the class specified in the parameter already exists, If it is deleted, otherwise it will be added.