Name
Element.getAttributeNode( ) — return the Attr node for the named attribute
Availability
DOM Level 1 Core
Synopsis
Attr getAttributeNode(String name
);
Arguments
-
name
The name of the desired attribute.
Returns
An Attr node whose descendants represent the value of the named
attribute, or null
if this element has no such
attribute.
Description
getAttributeNode( )
returns an Attr node that
represents the value of a named attribute. Note that this Attr node
can also be obtained through the attributes
property inherited from the Node interface.
The attribute value is represented by the descendants of the Attr
nodes. In HTML documents, an Attr node has a single Text node child,
and it is always easier to query an attribute value by calling
getAttribute( )
, which returns the value as a
string. getAttributeNode( )
is necessary only when
you are working with XML documents that contain entity references in
their attribute values.
Get JavaScript: The Definitive Guide, Fourth 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.