- Introduction
- DOM
- DOM Living Standard
-
"The DOM" is an API for accessing and manipulating documents.
-
- Introduction to the DOM
- DOM Living Standard
- Web APIs
- Window #interface
- Document #interface
- Document.head #HTMLHeadElement
- Document.body #HTMLBodyElement #or #HTMLFrameSetElement #deprecated #or null
- Document.forms #HTMLCollection
- Navigator #interface
- Screen #interface
- Location #interface
- History
- console
- Render Tree
- CSS
- JavaScript vs DOM
- Web APIs
- Accessing the DOM
- Web APIs
- Document #interface
- Document.getElementById()
- returns
-
An
Element
object describing the DOM element object matching the specified ID, ornull
if no matching element was found in the document.
-
- returns
- Document.getElementsByClassName()
- returns
-
A live
HTMLCollection
of found elements.
-
- returns
- Document.getElementsByTagName()
- returns
-
A live
HTMLCollection
of found elements in the order they appear in the tree.
-
- returns
- Document.querySelector()
- returns
-
An
Element
object representing the first element in the document that matches the specified set of CSS selectors, ornull
is returned if there are no matches.
-
- returns
- Document.querySelectorAll()
- returns
-
A non-live
NodeList
containing oneElement
object for each element that matches at least one of the specified selectors or an emptyNodeList
in case of no matches.
-
- returns
- Document.getElementById()
- Element #interface
- HTMLCollection #interface
- NodeList #interface
- Document #interface
- HTML
- Emmet
- Nodes
-
Web APIs
-
Node #interface
-
Node.childNodes #read-only
-
A live
NodeList
containing the children of the node.
-
-
Node.nodeType #read-only
-
Returns an
unsigned short
representing the type of the node. Possible values are:Name Value ELEMENT_NODE
1
ATTRIBUTE_NODE
2
TEXT_NODE
3
CDATA_SECTION_NODE
4
PROCESSING_INSTRUCTION_NODE
7
COMMENT_NODE
8
DOCUMENT_NODE
9
DOCUMENT_TYPE_NODE
10
DOCUMENT_FRAGMENT_NODE
11
-
-
Node.nodeName #read-only
-
-
- Traversing the DOM
-
Web APIs
-
Node
- Node.parentNode #read-only
-
A
Node
that is the parent of the current node. The parent of an element is anElement
node, aDocument
node, or aDocumentFragment
node.
-
- Node.parentElement #read-only
-
An
Element
that is the parent element of the current node, ornull
if there isn't one.
-
- Node.previousSibling #read-only
-
A
Node
representing the previous sibling of the current node, ornull
if there are none.
-
- Node.nextSibling #read-only
-
A
Node
representing the next sibling of the current node, ornull
if there are none.
-
- Node.firstChild #read-only
-
A
Node
, ornull
if there are none.
-
- Node.lastChild #read-only
-
A
Node
that is the last child of the node, ornull
is there are no child nodes.
-
- Node.hasChildNodes()
- returns
-
A
boolean
value that istrue
if the node has child nodes, andfalse
otherwise.
-
- returns
- Node.childNodes #read-only
- A live
NodeList
containing the children of the node.
- A live
- Node.parentNode #read-only
-
Element
- Element.previousElementSibling #read-only
-
A
Element
object, ornull
.
-
- Element.nextElementSibling #read-only
-
A
Element
object, ornull
.
-
- Element.firstElementChild #read-only
-
An
Element
object, ornull
.
-
- Element.lastElementChild #read-only
-
An
Element
object, ornull
.
-
- Element.children #read-only
-
An
HTMLCollection
which is a live, ordered collection ... If the element has no element children, then children is an empty list with alength
of 0.
-
- Element.previousElementSibling #read-only
-
- Creating, Removing and Cloning DOM Elements
- Web APIs
- Document
- Document.createElement()
-
A new
HTMLElement
is returned if the document is anHTMLDocument
, which is the most common case. Otherwise a newElement
is returned.
-
- Document.createElement()
- Node
- Node.appendChild(aChild)
- returns
-
A
Node
that is the appended child (aChild
), except ...
-
- returns
- Node.insertBefore()
-
Returns the added child.
-
- Node.replaceChild()
- returns
-
The replaced
Node
.
-
- returns
- Node.removeChild()
- Node.cloneNode()
- returns
-
The new
Node
cloned.
-
- returns
- Node.textContent
-
A string, or
null
.
-
- Node.appendChild(aChild)
- Element
- Element.innerHTML
-
A string containing the HTML serialization of the element's descendants.
-
- Element.remove()
- Element.innerHTML
- HTMLElement
- HTMLElement.innerText
-
A string representing the rendered text content of an element.
-
- HTMLElement.innerText
- Document
- Where to next
- My document and code are different from the official version.