bapp05.indd 02/17/2015 Page 523
Manipulating Content,
Attributes, and Custom Data
METHOD/PROPERTY DESCRIPTION RETURN
VALUEAT TRIBUTESattr(name) Returns the attribute value for the speci-
fi ed attribute from the fi rst element present
in a selection. If no element is present, the
method returns undefined.String,
Undefi nedattr(object) Allows you to set attributes via the specifi ca-
tion of key, value pairs. For example:
attr({
id : 'idName',
href : '/example.html',
title : 'Tooltip text.'
});jQueryattr(key, value) Allows you to specify an attribute by pro-
viding the name of the attribute in the
key argument and its value in the value
argument.jQueryattr(key, function) Sets an attribute’s value depending on the
return value of the callback function that you
specify. The callback function is executed
within the context of each selected ele-
ment, where each selected element can be
accessed within the function via this.jQueryE
continues