This page is In Progress

Notice: The WebPlatform project has been discontinued when the Stewards partnership agreement ended in September 2015. This site has been frozen, and the assets we have created will remain.

Element

Summary

Represents an node of type element in the DOM.

Inherits from NodeNode

Properties

XMLDocument
:

XMLNS attribute
:

childElementCount
Returns the number of direct children of this node that are elements. Read-only.
children
Retrieves a live collection of child elements of an element.
classList
Reflects the class attribute as an ordered list of the whitespace separated class names and has convenience methods for add, remove, contains and more.

code
:

entities
:

error
:

firstElementChild
Retrieves the first child of this node that is an element, if there is one, or null otherwise. Read-only.

htmlText
:

internalSubset
:

isTextEdit
:

lastElementChild
Retrieves the last child of this node that is an element, if there are any element children, or null otherwise. Read-only.

media
:

nextElementSibling
Retrieves the element node that is a sibling to this element node (a direct child of the same parent) and is immediately after it in the DOM tree, ignoring text nodes, comment nodes and any other non-element nodes. If there is no next element sibling, the property value is null. Read-only.

notations
:

onerror
:

onload
:

onloadend
:

onloadstart
:

onprogress
:

ownerElement
:

parent
:

parentElement
Retrieves the parent node of this DOM node, if the parent is an element node; null if the parent is not an element or if there is no parent. Read-only.

parentTextEdit
:

previousElementSibling
Retrieves the element node that is a sibling to this element node (a direct child of the same parent) and is immediately previous to it in the DOM tree, ignoring text nodes, comment nodes and any other non-element nodes. If there is no previous element sibling, the property value is null. Read-only.

readyState
:

result
:

size
:

systemLanguage
:

type
:

Methods

msWriteProfilerMark
:

querySelector
Returns the first element that matches the provided selector.
querySelectorAll
Returns a list of elements that match a provided selector.

RangeException
:

createControlRange
:

getAdjacentText
Non standard. Gets a text from a given location around the edges of the element.
getAttribute
Returns the value of the content attribute.
getAttributeNS
Returns the value of the content attribute within a specified namespace.
getAttributeNode
Retrieves an attribute node by name.
getAttributeNodeNS
Gets an attribute node that matches the specified namespace and name.
hasAttribute
Determines whether a content attribute exists on an element.
hasAttributeNS
Determines whether a content attribute in a specified namespace exists on an element.

inRange
:

insertAdjacentHTML
Parses and inserts HTML code at or beyond the edges of an element within the document hierarchy.

isEqual
:

item
:

releasePointerCapture
Releases a pointer captured by an element (using the setPointerCapture method).
removeAttribute
Removes a specified content attribute from an element.
removeAttributeNS
Removes a specified content attribute in a specified namespace from an element.

removeAttributeNode
:

requestFullscreen
The requestFullscreen method provides a way for presenting web content using the user’s entire screen. The API lets you easily direct the browser to make an element — and its children, if any — occupy the full available screen space, without borders or other chrome elements.
requestPointerLock
requestPointerLock lets you lock the target of mouse events to a single element while hiding the cursor.

scrollByLines
:

scrollByPages
:

scrollIntoView
Scrolls the page to the point where the element shows up.

scrollIntoViewIfNeeded
:

setAttribute
Sets the value of a content attribute.
setAttributeNS
Sets the value of a content attribute in a specified namespace.

setAttributeNode
:

setAttributeNodeNS
:

setPointerCapture
Assigns a specified pointer to an element. This method is used to ensure that an element continues to receive pointer events even if the contact moves off the element.

Events

error
The onerror event occurs when the request could not be completed because of an error.
load
After the onload event has occurred, responseText contains the complete server response.
progress
When the onprogress event occurs, partial data can be retrieved using responseText.
timeout
The ontimeout event occurs if the ontimeout period elapses before the onload event occurs.

change
:

cuechange
:

durationchange
:

emptied
:

ended
:

hashchange
:

help
:

input
:

layoutcomplete
:

load
:

loadeddata
:

loadedmetadata
:

loadstart
:

losecapture
:

move
:

moveend
:

movestart
:

offline
:

online
:

page
:

paste
:

pause
:

play
:

playing
:

propertychange
:

ratechange
:

readystatechange
:

reset
:

resize
:

resizeend
:

resizestart
:

seeked
:

seeking
:

stalled
:

submit
:

suspend
:

timeupdate
:

unload
:

volumechange
:

waiting
:

error
:

load
:

onabort
:

onzoom
:

resize
:

scroll
:

unload
:

Inherited from Node

Properties

attributes
Associatve array containing the attributes of node.
childNodes
Gets a collection of direct Node descendants of the Node, including Element, Text and any other type of nodes.
firstChild
Gets a reference to the first child node in the childNodes collection of the object. If the node is childless, null is returned.
lastChild
Gets a reference to the last child in the childNodes collection of an object.
localName
Retrieves the local name of the fully qualified XML declaration for a node.
namespaceURI
Retrieves the namespace URI of the fully qualified XML declaration for a node.
nextSibling
Retrieves the next child node of the parent of the node.
nodeName
Gets the name of a particular type of node.
nodeType
Retrieves the type of the requested node.
nodeValue
Gets or sets the value of a Node, if the type of Node supports it.
ownerDocument
Retrieves the document object associated with the node.
parentNode
Retrieves the parent node in the document hierarchy.
prefix
Sets or retrieves the prefix of the fully qualified XML declaration for a node.
previousSibling
Retrieves the previous child node of the parent of the node.
textContent
Sets or retrieves the text content of a node and any child nodes.

Methods

appendChild
Appends an element as a child to the object.
cloneNode
Copies a reference to the object from the document hierarchy.
compareDocumentPosition
Compares the position of two nodes in a document.
empty
Cancels the current selection, sets the selection type to none, and sets the item property to null.
hasAttributes
Returns whether this node (if it is an element) has any attributes
hasChildNodes
Gets a value that indicates whether the Node has any direct Node descendant of any type.
insertBefore
Inserts a child into the node, immediately before the specified reference child node.
isDefaultNamespace
Indicates whether or not a namespace is the default namespace for a document.
isEqualNode
Determines whether two nodes are equal in their type, name and namespace.
isSameNode
Determines if two nodes are the same node.
isSupported
Returns a value indicating whether or not the object supports a specific DOM standard.
lookupNamespaceURI
Gets the URI of the namespace associated with a namespace prefix, if any.
lookupPrefix
Gets the namespace prefix associated with a URI, if any.
normalize
Merges adjacent DOM objects to produce a normalized document object model.
removeChild
Removes a child node from a node.
replaceChild
Replaces an existing child node with a new child node.

Events

No events.

Notes

Elements may have attributes associated with them; use the attributes property to retrieve the set of all attributes for an element. There are methods on this object to retrieve either an attribute by name (getAttributeNode) or an attribute value by name (getAttribute). In XML, where an attribute value may contain entity references, an attribute should be retrieved to examine the possibly fairly complex sub-tree representing the attribute value. On the other hand, in HTML, where all attributes have simple string values, methods to directly access an attribute value can safely be used as a convenience.

Related specifications

DOM Level 3 Core
Recommendation

Attributions