-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
63 lines (42 loc) · 1.34 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
title: "DocumentFragment: append() method"
short-title: append()
slug: Web/API/DocumentFragment/append
page-type: web-api-instance-method
browser-compat: api.DocumentFragment.append
---
{{APIRef("DOM")}}
The **`DocumentFragment.append()`** method
inserts a set of {{domxref("Node")}} objects or strings after
the last child of the document fragment. Strings
are inserted as equivalent {{domxref("Text")}} nodes.
This method appends a child to a `DocumentFragment`. To append to an arbitrary element in the tree, see {{domxref("Element.append()")}}.
## Syntax
```js-nolint
append(param1)
append(param1, param2)
append(param1, param2, /* …, */ paramN)
```
### Parameters
- `param1`, …, `paramN`
- : A set of {{domxref("Node")}} objects or strings to insert.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
- `HierarchyRequestError` {{DOMxRef("DOMException")}}
- : Thrown when the node cannot be inserted at the specified point in the hierarchy.
## Examples
### Appending an element to a document fragment
```js
let fragment = new DocumentFragment();
let div = document.createElement("div");
fragment.append(div);
fragment.children; // HTMLCollection [<div>]
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("DocumentFragment.prepend()")}}
- {{domxref("Element.append()")}}