You are here: Reference > JavaScript > client-side > element handling

Element handling objects, properties and methods in JavaScript

Base objects:
Object Support Description
window
Represents the browser window, frame window or dialog window of a HTML document.
document
Represents an entire HTML document and provides possibilities for accessing, creating and manipulating all elements in the document.
body
Specifies the main body of an HTML document.
DocumentFragment
The DocumentFragment object is a context-free container that is similar to the document object.
implementation
Contains information about the features supported by the browser and provides methods for creating base objects.
namespace
Represents a namespace that has been declared for custom elements in HTML.
Collections:
Object Support Description
all
Represents a collection of all elements contained by an element or the entire document.
anchors
Represents a collection of all anchor elements in the document that have a name property specified.
applets
Represents a collection of all applet elements in the current document.
areas
Represents a collection of all area elements in a map element.
cells
Represents a collection of all td or th elements that belong to a table or tr element.
childNodes
Represents a collection of all nodes that are direct descendants of an element.
children
3.5
Represents a collection of all element nodes that are direct descendants of an element.
elements
Represents a collection of all form control elements in a form.
embeds
Represents a collection of all embed elements in the current document.
forms
Represents a collection of all form elements in the current document.
frames
Represents a collection of all window objects that belong to frame and iframe elements in the current document.
images
Represents a collection of all img elements in the current document.
links
Represents a collection of all anchor and area elements in the current document that have a href property specified.
namespaces
Represents a collection of namespaces that have been declared for custom elements in HTML.
options
Represents a collection of all option elements in a select element.
rows
Represents a collection of tr elements in a table, tfoot, thead or tbody element.
scripts
Represents a collection of all script elements in the current document.
tBodies
Represents a collection of tbody elements in a table element.
Properties:
Property Support Description
canHaveChildren
Retrieves a Boolean value that indicates whether the element can contain child elements.
caption
(table)
Returns the caption element of the current table object.
cellIndex
(td, th)
Returns a zero-based integer that indicates the position of a cell (td or th) in the cells collection of a table row.
childElementCount
93.5
Returns the number of element nodes that are direct descendants of the current element.
documentElement
(document, XMLDocument)
Returns a reference to the root element node of the document.
firstChild
Returns a reference to the first child of the current element.
firstElementChild
93.5
Returns a reference to the first child element of the current element.
frameElement
(window)
Returns a reference to the frame or iframe element that hosts the current window in the parent document.
index
(optgroup, option)
Specifies or returns an integer that indicates the position of an option element within a selection list.
lastChild
Returns a reference to the last child of the current element.
lastElementChild
93.5
Returns a reference to the last child element of the current element.
nextElementSibling
93.5
Returns a reference to the next child element of the current element's parent.
nextSibling
Returns a reference to the next child of the current element's parent.
nodeName
Returns the name of the current node.
nodeType
Returns an integer that indicates the type of the node.
nodeTypedValue
(attribute, Element)
Sets or returns the value of the node in its data type. The data type of a node can be defined with the dataType property.
nodeTypeString
(attribute, Element, ...)
Returns the type of the current node as a string.
nodeValue
Sets or returns the value of the current node.
offsetParent
Returns a reference to the closest ancestor element in the DOM hierarchy from which the position of the current element is calculated.
ownerDocument
Returns the document object that contains the current node.
parent
(window)
Returns a reference to the immediate parent window object in the window hierarchy.
parentElement
Returns the parent element of the object in the DOM hierarchy.
parentNode
Returns the parent element of the current node in the DOM hierarchy.
parentWindow
(document)
Returns a reference to the window object that contains the current document.
previousElementSibling
93.5
Returns a reference to the previous child element of the current element's parent.
previousSibling
Returns a reference to the previous node of the current element's parent.
rowIndex
(tr)
Returns the position of a row in the rows collection of the table.
sourceIndex
Returns the position of the current object in the all collection of the document.
tagName
Returns the tag name of the current element.
tFoot
(table)
Returns a reference to the tfoot element of the table.
tHead
(table)
Returns a reference to the thead element of the table.
Methods:
Method Support Description
add
(areas)
Inserts an area element into the current collection at the specified position.
adoptNode
(document, XMLDocument)
9
Moves a node from another document to the current document.
appendChild
Inserts an element after the last child of the current element.
applyElement
Inserts the specified element as a child or parent of the current element.
cloneNode
Returns an exact copy of the current node.
add
(options)
Inserts an option element into the current collection at the specified position.
contains
Returns whether the specified element is a descendant of the current element.
createCaption
(table)
Creates an empty caption element and adds it to the current table.
createComment
(document, XMLDocument)
Creates a CommentNode element from the specified text.
createDocument
(implementation)
9
Creates an XML document object.
createDocumentFragment
(document, XMLDocument)
Creates an empty DocumentFragment object.
createDocumentType
(implementation)
9
Creates a new doctype object.
createElement
(document, XMLDocument)
Creates an element with the specified tag name.
createElementNS
(document, XMLDocument)
9
Creates an element with the specified namespace prefix and name.
createTextNode
(document, XMLDocument)
Creates a new TextNode from the specified text.
createTFoot
(table)
Creates an empty tfoot element and adds it to the current table.
createTHead
(table)
Creates an empty thead element and adds it to the current table.
deleteCaption
(table)
Removes the first caption element from the current table.
deleteCell
(tr)
Removes a cell from the current row.
deleteRow
(table, tbody, tfoot, thead)
Removes a row from the current table, thead, tfoot or tbody element.
deleteTFoot
(table)
Removes the tfoot element from the current table.
deleteTHead
(table)
Removes the thead element from the table.
getAdjacentText
Returns the contents of the TextNode located at the specified position relative to the current element.
getElementById
(document, XMLDocument)
Returns the element with the specified id in the current document.
getElementsByClassName
93
Returns a NodeList collection that contains all descendant elements of the current element with the specified class name.
getElementsByName
(document, XMLDocument)
Returns a NodeList collection that contains all elements in the current document with the specified name attribute.
getElementsByTagName
Returns a NodeList collection that contains all descendant elements of the current element with the specified tag name.
getElementsByTagNameNS
9
Returns a NodeList collection that contains all descendant elements of the current element with the specified namespace URI and local name.
hasChildNodes
Returns whether the current node has any child nodes or not.
importNode
(document, XMLDocument)
9
Copies a node from another document to the current document.
insertAdjacentElement
Inserts an element at the specified position relative to the current element.
insertAdjacentHTML
Inserts a HTML formatted text at the specified position relative to the current element.
insertAdjacentText
Creates a new TextNode from the specified text and inserts it at the specified position relative to the current element.
insertBefore
Inserts an element before the specified child of the current element.
insertCell
(tr)
Creates an empty cell element and inserts it into the current row element at the specified position.
insertRow
(table, tbody, tfoot, thead)
Creates an empty row element and inserts it into the current table, thead, tfoot or tbody element.
isEqualNode
9
Returns whether the current node is equal to the specified one.
isSameNode
9
Returns whether the current node is the same node as the specified one.
moveRow
(table, tbody, tfoot, thead)
Moves a row to a new position in the current table, thead, tfoot or tbody element.
querySelector
83.5
Returns a reference to the first descendant element of the current element, that matches the specified selectors.
querySelectorAll
83.5
Returns a NodeList collection that contains all descendant elements of the current element that match the specified selectors.
remove
(areas)
Removes the area element at the specified position from the current collection.
remove
(options)
Removes the option element at the specified position from the current collection.
removeChild
Removes the specified child node from the current element.
removeNode
Removes the current element with or without its children from the document tree.
replaceAdjacentText
Replace the contents of the TextNode located at the specified position relative to the current element with the specified text.
replaceChild
Replaces the specified child element of the current element with a new element.
replaceNode
Replaces the current element with the specified element.
selectSingleNode
(XMLDocument)
Returns the first node that matches the specified XPath expression on the current node.
swapNode
Interchanges the positions of the current element and the specified element in the document hierarchy.

Objects, properties and methods that provide complex functionality for navigating or iterating through the document hierarchy:

Objects:
Object Support Description
NodeIterator
93.5
Represents the result of the createNodeIterator method as an ordered list.
TreeWalker
9
Represents the result of the createTreeWalker method as a tree.
XPathResult
Represents the result of the evaluation of an XPath expression.
Properties:
Property Support Description
currentNode
(TreeWalker)
9
Sets or retrieves a reference to the node where the pointer of the TreeWalker is currently positioned.
filter
(NodeIterator, TreeWalker)
9
Returns the filtering that function belongs to the NodeIterator or TreeWalker object.
resultType
(XPathResult)
Retrieves the type of the result represented by the XPathResult object.
root
(NodeIterator, TreeWalker)
9
Returns the root element that was used to create the NodeIterator or TreeWalker object.
singleNodeValue
(XPathResult)
Returns the single node represented by the current XPathResult object.
snapshotLength
(XPathResult)
Returns the length of the snapshots collection.
stringValue
(XPathResult)
If the type of the result represented by the XPathResult object is string, returns the value of the result.
whatToShow
(NodeIterator, TreeWalker)
9
Returns an integer that identifies the types of nodes that can be shown by the current NodeIterator or TreeWalker object.
Methods:
Method Support Description
createNodeIterator
(document, XMLDocument)
93.5
Creates a NodeIterator object that can be used to iterate through the nodes in a subtree.
createNSResolver
(document, XMLDocument)
Creates an XPathNSResolver object from the specified node that can be used to get namespace URIs from namespace prefixes in the scope of the node.
createTreeWalker
(document, XMLDocument)
9
Creates a TreeWalker object that can be used to navigate through the nodes in a subtree.
detach
(NodeIterator)
93.5
Releases the current NodeIterator object and puts the iterator into the invalid state.
evaluate
(document, XMLDocument)
Evaluates an XPath expression and creates an XPathResult object that represents the result.
firstChild
(TreeWalker)
9
Finds the first child of the current node in the tree represented by the current TreeWalker object. If it exists, it will be made the current node and returned, else the current node is retained and null is returned.
iterateNext
(XPathResult)
Moves the iterator to the next node in the result set and returns the node referenced by the current iterator.
lastChild
(TreeWalker)
9
Finds the last child of the current node in the tree represented by the current TreeWalker object. If it exists, it will be made the current node and returned, else the current node is retained and null is returned.
nextNode
(NodeIterator, TreeWalker)
9
Finds the next node relative to the current node in the ordered list represented by the current NodeIterator object or in the tree represented by the current TreeWalker object. If it exists, it will be made the current node and returned, else the current node is retained and null is returned.
nextSibling
(TreeWalker)
9
Finds the next sibling of the current node in the tree represented by the current TreeWalker object. If it exists, it will be made the current node and returned, else the current node is retained and null is returned.
parentNode
(TreeWalker)
9
Finds the parent node of the current node in the tree represented by the current TreeWalker object. If it exists, it will be made the current node and returned, else the current node is retained and null is returned.
previousNode
(NodeIterator, TreeWalker)
9
Finds the previous node relative to the current node in the ordered list represented by the current NodeIterator object or in the tree represented by the current TreeWalker object. If it exists, it will be made the current node and returned, else the current node is retained and null is returned.
previousSibling
(TreeWalker)
9
Finds the previous sibling of the current node in the tree represented by the current TreeWalker object. If it exists, it will be made the current node and returned, else the current node is retained and null is returned.
snapshotItem
(XPathResult)
Returns a matching node from the snapshots collection.
User Contributed Comments

Post Content

Post Content