-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
67 lines (47 loc) · 1.02 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
64
65
66
67
---
title: Element.remove()
slug: Web/API/Element/remove
page-type: web-api-instance-method
tags:
- API
- Element
- DOM
- Method
browser-compat: api.Element.remove
---
{{APIRef("DOM")}}
The **`Element.remove()`** method removes the element from the DOM.
## Syntax
```js
remove()
```
### Parameters
None.
### Return value
None ({{jsxref("undefined")}}).
## Examples
### Using `remove()`
```html
<div id="div-01">Here is div-01</div>
<div id="div-02">Here is div-02</div>
<div id="div-03">Here is div-03</div>
```
```js
const element = document.getElementById('div-02');
element.remove(); // Removes the div with the 'div-02' id
```
### `Element.remove()` is unscopable
The `remove()` method is not scoped into the `with` statement.
See {{jsxref("Symbol.unscopables")}} for more information.
```js
with(node) {
remove();
}
// ReferenceError: remove is not defined
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Polyfill](https://github.com/chenzhenxi/element-remove)