Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

DOM — Document Object Model

The DOM represents a document as a tree of objects that JavaScript can read and modify. DOM manipulation includes creating, attaching, updating, and removing nodes. It is an interface supplied by the browser environment, not ECMAScript language syntax.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

{
  const parent = document.createElement("div");
  const element = document.createElement("p");
  element.textContent = "Hello";
  parent.appendChild(element);
}

The DOM (Document Object Model) is an object-based representation of a document as a tree. The document, elements, and text are different kinds of nodes; an element is not the same thing as the text it contains. DOM manipulation means programmatically reading and changing this tree, for example by updating text or adding elements.

The document object exposes document operations. document.createElement("p") creates an element but does not automatically place it on the page. Assigning to textContent sets text content rather than interpreting it as markup. parent.appendChild(element) attaches a node to a parent; if the node already has a parent, it moves the node rather than copying it. Changing the visible page requires working with nodes attached to its document.

In the example, both elements remain outside the page tree. Reading container.textContent still returns its descendant's text, so the result is deterministic and independent of existing page content. The example does not rely on elements that must already exist.

The ECMAScript specification defines the language, not DOM APIs. The environment supplies additional objects and functions. The WHATWG DOM Standard defines createElement, textContent, and appendChild. Browser support for these APIs must be checked separately. No ECMAScript edition is therefore assigned to the DOM here. Having Node 24 in the repository does not establish the availability of document or browser API support; the example requires an environment with a DOM.

Examples

const container = document.createElement("div");
const message = document.createElement("p");
message.textContent = "Hello, DOM!";
container.appendChild(message);
console.log(container.textContent);

Result

Hello, DOM!

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources