jQuery Setting value of HTML attribute


Example

If you want to add an attribute to some element you can use the attr(attributeName, attributeValue) function. For example:

$('a').attr('title', 'Click me');

This example will add mouseover text "Click me" to all links on the page.

The same function is used to change attributes' values.