Definition and Usage
The Element object represents an element in the HTML document.
The Element object can have child nodes of type Element, Text, Comment, CDATASection, ProcessingInstruction, and EntityReference.
The Element object can have attributes, which have the node type Attr.
Note: The Element object can also use the properties and methods of the Node object.
Browser Support
The Element object is supported in all major browsers.
Element Object Properties
The "DOM" column indicates in which DOM Level the property was introduced.
Property | Description | DOM |
---|---|---|
schemaTypeInfo | Returns the type information of the element. | 3 |
tagName | Returns the tag name of the element | 1 |
Element Object Methods
The "DOM" column indicates in which DOM Level the method was introduced.
Method | Description | DOM |
---|---|---|
getAttribute() | Returns the specified attribute value | 1 |
getAttributeNS() | Returns the specified attribute value, with the specified namespace. For XML DOM only | 2 |
getAttributeNode() | Returns the specified attribute node | 1 |
getAttributeNodeNS() | Returns the specified attribute node, with the specified namespace. For XML DOM only | 3 |
getElementsByTagName() | Returns a collection of all child elements with the specified tagname | 1 |
getElementsByTagNameNS() | Returns a collection of all child elements with the specified tagname and namespace. For XML DOM only | 2 |
hasAttribute() | Returns true if the element has the specified attribute, otherwise it returns false | 2 |
hasAttributeNS() | Returns true if the element has the specified attribute, with the specified namespace, otherwise it returns false. For XML DOM only | 2 |
removeAttribute() | Removes the specified attribute | 1 |
removeAttributeNS() | Removes the attribute with the specified name and namespace. For XML DOM only | 2 |
removeAttributeNode() | Removes the specified attribute node, and returns the removed node | 1 |
setAttribute() | Sets or changes the specified attribute, to the specified value | 1 |
setAttributeNS() | Sets or changes the specified attribute, with the specified namespace, to the specified value. For XML DOM only | 2 |
setAttributeNode() | Sets or changes the specified attribute node | 1 |
setAttributeNodeNS() | Sets or changes the specified attribute node | 2 |
setIdAttribute() | 3 | |
setIdAttributeNS() | 3 | |
setIdAttributeNode() | 3 |