jQuery Attributes Setting value of HTML attribute


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.