Name
Attr — an element attribute
Synopsis
An Attr object represents an attribute of an Element node. 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.
Since attribute values can be completely represented by
strings, it is not usually necessary to use the Attr interface at
all. In most cases, the easiest way to work with attributes is with
the Element.getAttribute() and
Element.setAttribute() methods.
These methods use strings for attribute values and avoid the use of
Attr objects altogether.
Properties
readonly stringlocalNameThe name of the attribute, not including any namespace prefix.
readonly stringnameThe name of the attribute, including the namespace prefix, if there is one.
readonly stringnamespaceURIThe URI that identifies the attribute’s namespace, or
nullif it doesn’t have one.readonly stringprefixThe namespace prefix of the attribute, or
nullif it doesn’t have one.stringvalueThe value of the attribute.
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