1.4

var box = query("#box");
box.append("<p>Peter Parker</p>");
box.css("color","red");
attr()
Returns the value of the specified attribute of the first element in a result set, or sets the value of
the specified attribute of each element in a result set.
l attr(attributeName)
l attr(attributeName, value)
attr(attributeName)
Returns the value of the specified attribute of the first element in a result set.
attributeName
String; the name of the attribute.
Examples
This script - with the selector img - stores the source of the first image in a variable.
var src = results.attr("src");
The following script looks up an element with the ID #table1 and stores its background color in
a variable.
var backgroundcolor = query("#table1").attr("bgcolor");
attr(attributeName, value)
Sets the value of the specified attribute of each element in a result set.
attributeName
String; the name of the attribute.
value
String; value for the attribute.
Page 186