Element.prototype.append
Inserts a set of Node objects or strings after the last child of the Element
Syntax
element.append(...nodes)Parameters
| Parameter | Type | Description |
|---|---|---|
| nodes | ...(Node | string)[] | A set of Node or string objects to insert |
Return Value
undefined
Examples
const div = document.createElement('div')
div.append('Hello ', document.createElement('strong'))
console.log(div.innerHTML)const list = document.querySelector('ul')!
const items = ['Apple', 'Banana', 'Cherry']
items.forEach(item => {
const li = document.createElement('li')
li.textContent = item
list.append(li)
})const header = document.querySelector('header')!
const nav = document.createElement('nav')
const logo = document.createElement('span')
header.append(logo, nav)Understanding Element.prototype.append
The Element.prototype.append method in JavaScript inserts a set of Node objects or strings after the last child of the Element. It belongs to the Element object and is one of the most widely used methods for working with element values in modern JavaScript and TypeScript applications.
The method signature is element.append(...nodes). It accepts 1 parameter: nodes. When called, it returns undefined. Understanding when and how to use append() helps you write more expressive, readable code.
Common use cases for Element.prototype.append include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like dom-appendchild, dom-prepend, dom-after, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Element.prototype.append is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
Element.prototype.appendChildAdds a node to the end of the list of children of a specified parent node
Element.prototype.prependInserts a set of Node objects or strings before the first child of the Element
Element.prototype.afterInserts a set of Node or string objects in the children list of this Element's parent, just after this Element
Element.prototype.beforeInserts a set of Node or string objects in the children list of this Element's parent, just before this Element
More Element Methods
Other methods in the Element object
Related Tools
More Element Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.