Favorites

DOM Node.appendChild() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Node.appendChild()
DOM Node MethodThis method is supported by all modern browsers.
Updated 28th November 2026

The appendChild() method adds a node as the last child of an element. If the node is already in the page, it is moved.

Description

The appendChild() method adds a node to the end of the list of children of a parent node. A node can only be in one place, so appending a node that is already in the document moves it. Appending a DocumentFragment moves all of its children.

The newer append() method is more flexible: it accepts several nodes and plain strings at once. appendChild() returns the node, which can be handy for chaining.

It can only append one node at a time and only accepts nodes, not strings, so text must be wrapped in document.createTextNode(). Appending a node that is an ancestor of the parent throws a HierarchyRequestError, since that would create a loop in the tree.

Syntax

parent.appendChild(child)

Parameters

  • childThe node to add as the last child.

Return Value

The appended node.

Example

<ul id="list">
  <li>One</li>
  <li>Two</li>
</ul>
const list = document.getElementById('list');
const li = document.createElement('li');
li.textContent = 'Three';
list.appendChild(li);
list.appendChild(list.firstElementChild);   // moves "One" to the end
console.log([...list.children].map(n => n.textContent));

Browser Support

The following information will show you the current browser support for the Node.appendChild() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee