Name
Attr: an attribute of a document element — DOM Level 1 Core: Node → Attr
Properties
-
readonly String name The name of the attribute.
readonly Element ownerElement[DOM Level 2]The Element object that contains this attribute, or
nullif the Attr object is not currently associated with any Element.-
readonly boolean specified trueif the attribute is explicitly specified in the document source or set by a script;falseif the attribute is not explicitly specified but a default value is specified in the document’s DTD.-
String value The value of the attribute. When reading this property, the attribute value is returned as a string. When you set this property to a string, it automatically creates a Text node that contains the same text and makes that Text node the sole child of the Attr object.
Description
An Attr object represents an attribute of an Element node.
Attr objects are associated with Element nodes but are not directly
part of the document tree (and have a null
parentNode property). You can obtain an Attr object
through the attributes property
of the Node interface or by calling the getAttributeNode( ) or getAttributeNodeNS( ) methods of the
Element interface.
The value of an attribute is represented by the descendant
nodes of an Attr node. In HTML documents, an Attr node always has a
single Text node child, and the value property provides a shortcut for
reading and writing the value of this child node.
The XML grammar allows XML documents to have attributes that consist of ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access