Element

< dom
Jump to: navigation, search

Element


W3C Recommendation

Summary

Represents an node of type element in the DOM.

Inherits from Node

Properties

API Name Summary
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
oneTimeOnly
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

API Name Summary
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

API Name Summary
error
load
progress
timeout
change
cuechange
durationchange
emptied
ended
hashchange
help
input
layoutcomplete
load
loadeddata
loadedmetadata
loadstart
losecapture
message Fires when the user sends a cross-document message or a message is sent from a Worker with postMessage.
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
… further results

Inherited from Node

Properties

API Name Summary
attributes Associatve array containing the attributes of node.
childNodes
firstChild
lastChild
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.
ownerDocument
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

API Name Summary
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
hasAttributes
hasChildNodes
insertBefore Inserts a node into the document hierarchy as a child node of a 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.

Needs Examples: This section should include examples.

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

Specification Status Related Changes
DOM Level 3 Core Recommendation Section 1.4

Compatibility

Desktop

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support ? ? ? ? ?

Mobile

Feature Android BlackBerry Chrome for mobile Firefox Mobile (Gecko) IE Mobile Opera Mobile Opera Mini Safari Mobile
Basic support ? ? ? ? ? ? ? ?

Attribution

This article contains content originally from external sources.

Portions of this content come from the Microsoft Developer Network: [Windows Internet Explorer API reference Article]