What is Attribute in JQuery?

All HTML elements have attributes. It provides additional information about an element. Let us see some example of attributes below.

  • class Name
  • id
  • title
  • name
  • src
  • style

Consider the HTML markup for an div element.

In the above HTML markup id, class are represents the element’s attributes, which consists of a name and a value. Jquery provide an easy way to manipulate the element attributes by using selectively.

How to get Attribute Value?

The attr() method can be used to either fetch the value of an attribute or perform the assigned operation on the onto all matched elements.

Example :

Explanation:

From the above code , title =”JQuery-Helpers” attribute has added with the value for all the div elements which has the class name “jQClass”.