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 string
localName
The name of the attribute, not including any namespace prefix.
readonly string
name
The name of the attribute, including the namespace prefix, if there is one.
readonly string
namespaceURI
The URI that identifies the attribute’s namespace, or
null
if it doesn’t have one.readonly string
prefix
The namespace prefix of the attribute, or
null
if it doesn’t have one.string
value
The value of the attribute.
Get JavaScript: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.