Element

The Element interface represents an object of a Document. This interface describes methods and properties common to all kinds of elements. Specific behaviors are described in interfaces which inherit from Element but add additional functionality. For example, the HTMLElement (en-US) interface is the base interface for HTML elements, while the SVGElement (en-US) interface is the basis for all SVG elements.

Languages outside the realm of the Web platform, like XUL through the XULElement interface, also implement it.

Properties

Inherits properties from its parents Node, and its own parent, EventTarget (en-US), and implements those of ParentNode, ChildNode, NonDocumentTypeChildNode (en-US), and Animatable.

Element.attributes (en-US) Schreibgeschützt
Returns a NamedNodeMap (en-US) that lists all attributes associated with the element.
ParentNode.childElementCount (en-US)
Is a Number representing the number of child nodes that are elements.
ParentNode.children (en-US)
Is a live HTMLCollection containing all child elements of the element, as a collection.
Element.classList Schreibgeschützt
Returns a DOMTokenList containing the list of class attributes.
Element.className
Is a DOMString representing the class of the element.
Element.clientHeight (en-US) Schreibgeschützt
Returns a Number representing the inner height of the element.
Element.clientLeft (en-US) Schreibgeschützt
Returns a Number representing the width of the left border of the element.
Element.clientTop (en-US) Schreibgeschützt
Returns a Number representing the width of the top border of the element.
Element.clientWidth (en-US) Schreibgeschützt
Returns a Number representing the inner width of the element.
ParentNode.firstElementChild (en-US)
Is a Element, the first direct child element of an element, or null if the element has no child elements.
Element.id (en-US)
Is a DOMString representing the id of the element.
Element.innerHTML
Is a DOMString representing the markup of the element's content.
ParentNode.lastElementChild (en-US)
Is a Element, the last direct child element of an element, or null if the element has no child elements.
NonDocumentTypeChildNode.nextElementSibling (en-US)
Is a Element, the element immediately following the given one in the tree, or null if there's no sibling node.
Element.outerHTML (en-US)
Is a DOMString representing the markup of the element including its content. When used as a setter, replaces the element with nodes parsed from the given string.
NonDocumentTypeChildNode.previousElementSibling (en-US)
Is a Element, the element immediately preceding the given one in the tree, or null if there is no sibling element.
Element.scrollHeight (en-US) Schreibgeschützt
Returns a Number representing the scroll view height of an element.
Element.scrollLeft
Is a Number representing the left scroll offset of the element.
Element.scrollLeftMax (en-US) Schreibgeschützt
Returns a Number representing the maximum left scroll offset possible for the element.
Element.scrollTop (en-US)
Is a Number representing the top scroll offset the an element.
Element.scrollTopMax (en-US) Schreibgeschützt
Returns aNumber representing the maximum top scroll offset possible for the element.
Element.scrollWidth Schreibgeschützt
Returns a Number representing the scroll view width of the element.
Element.shadowRoot (en-US) Schreibgeschützt
...
Element.tagName (en-US) Schreibgeschützt
Returns a String with the name of the tag for the given element.
Element.undoManager Schreibgeschützt
Returns the UndoManager associated with the element.
Element.undoScope
Is a Boolean indicating if the element is an undo scope host, or not.

Event handlers

Element.ongotpointercapture (en-US)
…
Element.onlostpointercapture (en-US)
…
Element.onwheel (en-US)
Returns the event handling code for the wheel event.

Methods

Inherits methods from its parents Node, and its own parent, EventTarget (en-US), and implements those of ParentNode, ChildNode, NonDocumentTypeChildNode (en-US), and Animatable.

EventTarget.addEventListener() (en-US)
Registers an event handler to a specific event type on the element.
Element.closest() (en-US)
Returns the Element, descendant of this element (or this element itself), that is the closest ancestor of the elements selected by the selectors given in parameter.
Element.createShadowRoot() (en-US)
…
EventTarget.dispatchEvent() (en-US)
Dispatches an event to this node in the DOM and returns a Boolean that indicates that at least one handler has not canceled it.
Element.find()
...
Element.findAll()
...
Animatable.getAnimationPlayers()
…
Element.getAttribute() (en-US)
Retrieves the value of the named attribute from the current node and returns it as an Object.
Element.getAttributeNS() (en-US)
Retrieves the value of the attribute with the specified name and namespace, from the current node and returns it as an Object.
Element.getAttributeNode() (en-US) Dies ist eine veraltete API und es wird nicht mehr garantiert, dass sie funktioniert.
Retrievse the node representation of the named attribute from the current node and returns it as an Attr (en-US).
Element.getAttributeNodeNS() (en-US) Dies ist eine veraltete API und es wird nicht mehr garantiert, dass sie funktioniert.
Retrieves the node representation of the attribute with the specified name and namespace, from the current node and returns it as an Attr (en-US).
Element.getBoundingClientRect()
...
Element.getClientRects() (en-US) TYPE of returnvalue????
Returns a collection of rectangles that indicate the bounding rectangles for each line of text in a client.
Element.getDestinationInsertionPoints()
…
Element.getElementsByClassName() (en-US)
Returns a live HTMLCollection that contains all descendant of the current element that posses the list of classes given in parameter.
Element.getElementsByTagName() (en-US)
Returns a live HTMLCollection containing all descendant elements, of a particular tag name, from the current element.
Element.getElementsByTagNameNS() (en-US)
Returns a live HTMLCollection containing all descendant elements, of a particular tag name and namespace, from the current element.
Element.hasAttribute()
Returns a Boolean indicating if the element has the specified attribute or not.
Element.hasAttributeNS() (en-US)
Returns a Boolean indicating if the element has the specified attribute, in the specified namespace, or not.
Element.insertAdjacentHTML
Parses the text as HTML or XML and inserts the resulting nodes into the tree in the position given.
Element.matches() (en-US)
Returns a Boolean indicating whether or not the element would be selected by the specified selector string.
Element.querySelector()
Returns Node...
Element.querySelectorAll
Returns a NodeList (en-US)...
Element.releasePointerCapture (en-US)
…
ChildNode.remove() (en-US)
Removes the element from the children list of its parent.
Element.removeAttribute()
Removes the named attribute from the current node.
Element.removeAttributeNS() (en-US)
Removes the attribute with the specified name and namespace, from the current node.
Element.removeAttributeNode() (en-US) Dies ist eine veraltete API und es wird nicht mehr garantiert, dass sie funktioniert.
Removes the node representation of the named attribute from the current node.
EventTarget.removeEventListener() (en-US)
Removes an event listener from the element.
Element.requestFullscreen()
Asynchronously asks the browser to make the element full-screen.
Element.requestPointerLock() (en-US)
Allows to asynchronously ask for the pointer to be locked on the given element.
Element.scrollIntoView()
Scrolls the page until the element gets into the view.
Element.setAttribute()
Sets the value of a named attribute of the current node.
Element.setAttributeNS() (en-US)
Sets the value of the attribute with the specified name and namespace, from the current node.
Element.setAttributeNode() (en-US) Dies ist eine veraltete API und es wird nicht mehr garantiert, dass sie funktioniert.
Sets the node representation of the named attribute from the current node.
Element.setAttributeNodeNS() (en-US) Dies ist eine veraltete API und es wird nicht mehr garantiert, dass sie funktioniert.
Setw the node representation of the attribute with the specified name and namespace, from the current node.
Element.setCapture() (en-US)
Sets up mouse event capture, redirecting all mouse events to this element.
Element.setPointerCapture() (en-US)
…

Specifications

Specification Status Comment
Web Animations Arbeitsentwurf Added the getAnimationPlayers() method.
UndoManager and DOMTransaction
Die Definition von 'Element' in dieser Spezifikation.
Bearbeiterentwurf Added the undoScope and undoManager properties.
Pointer Events
Die Definition von 'Element' in dieser Spezifikation.
Veraltet Added the following event handlers: ongotpointercapture and onlostpointercapture.
Added the following methods: setPointerCapture() and releasePointerCapture().
Selectors API Level 2
Die Definition von 'Element' in dieser Spezifikation.
Veraltet Added the following methods: matches() (implemented as mozMatchesSelector()), find(), findAll().
Selectors API Level 1
Die Definition von 'Element' in dieser Spezifikation.
Veraltet Added the following methods: querySelector() and querySelectorAll().
Pointer Lock
Die Definition von 'Element' in dieser Spezifikation.
Anwärter Empfehlung Added the requestPointerLock() method.
Fullscreen API
Die Definition von 'Element' in dieser Spezifikation.
Lebender Standard Added the requestFullscreen() method.
DOM Parsing and Serialization
Die Definition von 'Element' in dieser Spezifikation.
Arbeitsentwurf Added the following properties: innerHTML, and outerHTML.
Added the following method: insertAdjacentHTML().
CSS Object Model (CSSOM) View Module
Die Definition von 'Element' in dieser Spezifikation.
Arbeitsentwurf Added the following properties: scrollTop, scrollLeft, scrollWidth, scrollHeight, clientTop, clientLeft, clientWidth, and clientHeight.
Added the following methods: getClientRects(), getBoundingClientRect(), and scrollIntoView().
Element Traversal Specification
Die Definition von 'Element' in dieser Spezifikation.
Veraltet Added inheritance of the ElementTraversal interface.
DOM
Die Definition von 'Element' in dieser Spezifikation.
Lebender Standard Removed the following methods: closest(), setIdAttribute(), setIdAttributeNS(), and setIdAttributeNode().
Removed the schemaTypeInfo property.
Modified the return value of getElementsByTag() and getElementsByTagNS().
Moved hasAttributes() form the Node interface to this one.
Document Object Model (DOM) Level 3 Core Specification
Die Definition von 'Element' in dieser Spezifikation.
Veraltet Added the following methods: setIdAttribute(), setIdAttributeNS(), and setIdAttributeNode(). These methods were never implemented and have been removed in later specifications.
Added the schemaTypeInfo property. This property was never implemented and has been removed in later specifications.
Document Object Model (DOM) Level 2 Core Specification
Die Definition von 'Element' in dieser Spezifikation.
Veraltet The normalize() method has been moved to Node.
Document Object Model (DOM) Level 1 Specification
Die Definition von 'Element' in dieser Spezifikation.
Veraltet Initial definition.

Browser compatibility

Wir konvertieren die Kompatibilitätsdaten in ein maschinenlesbares JSON Format. Diese Kompatibilitätstabelle liegt noch im alten Format vor, denn die darin enthaltenen Daten wurden noch nicht konvertiert. Finde heraus wie du helfen kannst! (en-US)
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 1.0 (1.7 oder früher) (Ja) (Ja) 1.0
children (Ja) 3.0 (1.9) 7.0 with a significant bug [1]
9.0 according to the spec
(Ja) Nicht unterstützt
childElementCount, nextElementSibling, previousElementSibling (Ja) 3.5 (1.9.1) 9.0 (Ja) (Ja)
firstElementChild, lastElementChild (Ja) 3.0 (1.9) 9.0 (Ja) (Ja)
classList (Ja) 3.6 (1.9.2)   (Ja) (Ja)
outerHTML (Ja) 11 (11) (Ja) (Ja) (Ja)
clientLeft, clientTop (Ja) 3.5 (1.9.1) (Ja) (Ja) (Ja)
getBoundingClientRect(), getClientRects() (Ja) 3.0 (1.9) (Ja) (Ja) (Ja)
querySelector(), querySelectorAll() 1.0 3.5 (1.9.1) 8.0 10.0 3.2 (525.3)
insertAdjacentHTML() 1.0 8 (8) 4.0 7.0 4.0 (527)
setCapture() Nicht unterstützt 4.0 (2) Nicht unterstützt Nicht unterstützt Nicht unterstützt
oncopy, oncut, onpaste Nicht unterstützt 3.0 (1.9) (Ja)   Nicht unterstützt
onwheel Nicht unterstützt 17 (17) Nicht unterstützt Nicht unterstützt Nicht unterstützt
ongotpointercapture, onlostpointercapture, setPointerCapture(), and releasePointerCapture() Nicht unterstützt Nicht unterstützt 10.0 MS (en-US) Nicht unterstützt Nicht unterstützt
matches() (Ja) with the non-standard name webkitMatchesSelector 3.6 (1.9.2) with the non-standard name mozMatchesSelector
34 (34) with the standard name
9.0 with the non-standard name msMatchesSelector 11.5 with the non-standard name oMatchesSelector
15.0 with the non-standard name webkitMatchesSelector
5.0 with the non-standard name webkitMatchesSelector
find() and findAll() Nicht unterstützt Nicht unterstützt Nicht unterstützt Nicht unterstützt Nicht unterstützt
requestPointerLock() 16.0 webkit (en-US), behind an about:flags
22.0 webkit (en-US) (with special cases, progressively lifted see [2])
14 (14)moz (en-US) Nicht unterstützt Nicht unterstützt Nicht unterstützt
requestFullscreen() 14.0 webkit (en-US) 10 (10) moz (en-US) 11.0 ms (en-US) 12.10
15.0 webkit (en-US)
5.1 webkit (en-US)
undoManager and undoScope Nicht unterstützt (Ja) (behind the dom.undo_manager.enabled pref) Nicht unterstützt Nicht unterstützt Nicht unterstützt
attributes ? 22 (22)
Before this it was available via the Node interface that any element inherits.
? ? ?
scrollTopMax() and scrollLeftMax() Nicht unterstützt 16 (16) Nicht unterstützt Nicht unterstützt Nicht unterstützt
closest() ? 35 (35) ? ? ?
hasAttributes() (Ja) 1.0 (1.7 oder früher) (on the Node interface)
35 (35) (on this interface
(Ja) (Ja) (Ja)
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 1.0 1.0 (1) (Ja) (Ja) 1.0
scrollTopMax() and scrollLeftMax() Nicht unterstützt 16.0 (16) Nicht unterstützt Nicht unterstützt Nicht unterstützt
closest() ? 35.0 (35) ? ? ?
hasAttributes() (Ja) 1.0 (1.0) (on the Node interface)
35.0 (35) (on this interface
(Ja) (Ja) (Ja)

[1] Internet Explorer 7 and 8 incorrectly return the comments as part of the children of an Element. This is fixed in Internet Explorer 9 and later.

[2] Chrome 16 allowed webkitRequestPointerLock() only in fullscreen; Chrome 21 for trusted web site (permission asked); Chrome 22 allowed it by default for all same-origin document; Chrome 23 allowed it in sandboxed <iframe> if the non-standard value webkit-allow-pointer-lock is set to the sandbox attribute.