DOM/domcore/Element

From W3C Wiki
< DOM‎ | domcore
Jump to: navigation, search

Element

The Element interface represents an element in an HTML or XML document. Elements may have attributes associated with them; since the Element interface inherits from Node, the generic Node interface attribute attributes may be used to retrieve the set of all attributes for an element.


Attributes

Name Description
namespaceURI ...
prefix ...
localName ...
tagName Returns the name of the element.
attributes ...
children ...
firstElementChild ...
lastElementChild ...
previousElementSibling ...
nextElementSibling ...
childElementCount ...


Methods

Name Description
getAttribute(name) Retrieves an attribute value by name.
getAttributeNS(namespace, localName) Retrieves an attribute value by local name and namespace URI.
setAttribute(qualifiedName, value) Adds a new attribute.
setAttributeNS(namespace, qualifiedName, value) Adds a new attribute.
removeAttribute(qualifiedName) Removes an attribute by name.
removeAttributeNS(namespace, localName) Removes an attribute by local name and namespace URI.
hasAttribute(qualifiedName) Returns true when an attribute with a given name is specified on this element or has a default value, false otherwise.
hasAttributeNS(namespace, localName) Returns true when an attribute with a given local name and namespace URI is specified on this element or has a default value, false otherwise.
getElementsByTagName(qualifiedName) Returns a list of all descendant Elements with a given tag name, in document order.
getElementsByTagNameNS(namespace, localName) Returns a list of all the descendant Elements with a given local name and namespace URI in document order.
getElementsByClassName(classNames) Returns the Element that has an class attribute with the given value.


DOM Core reference

DOM Core specification defines the Interface Element in 5.6 Interface Element.