Name
Element — an HTML or XML element
Availability
DOM Level 1 Core
Inherits from/Overrides
Node → Element
Subinterfaces
HTMLElement
Properties
-
readonly String tagName The tag name of the element. This is the string “P” for an HTML
<p>element, for example. For HTML documents, the tag name is returned in uppercase, regardless of its capitalization in the document source. XML documents are case-sensitive, and the tag name is returned exactly as it is written in the document source. This property has the same value as thenodeNameproperty of the Node interface.
Methods
-
getAttribute( ) Returns the value of a named attribute as a string.
-
getAttributeNS( )[DOM Level 2] Returns the string value of an attribute specified by local name and namespace URI. Useful only with XML documents that use namespaces.
-
getAttributeNode( ) Returns the value of a named attribute as an Attr node.
-
getAttributeNodeNS( )[DOM Level 2] Returns the Attr value of an attribute specified by local name and namespace URI. Useful only with XML documents that use namespaces.
-
getElementsByTagName( ) Returns an array (technically, a NodeList) of all descendant Element nodes of this element that have the specified tag name, in the order in which they appear in the document.
-
getElementsByTagNameNS( )[DOM Level 2] Like
getElementsByTagName( ), except that the element tag name is specified by local name and namespace URI. Useful only with XML documents that use namespaces.-
hasAttribute( )[DOM Level 2] Returns
trueif ...
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