blob: 4c75a0bf529e0fd4320980d767e890613908c253 (
plain)
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
|
---
title: Element.remove()
slug: Web/API/Element/remove
tags:
- API
- Element
- DOM
- Method
browser-compat: api.Element.remove
translation_of: Web/API/Element/remove
---
<div>{{APIRef("DOM")}}</div>
<p><code><strong>Element.remove()</strong></code> は所属するツリーから要素を削除します。</p>
<h2 id="Syntax">構文</h2>
<pre class="brush: js">remove()</pre>
<h2 id="Example">例</h2>
<h3 id="Using_remove"><code>remove()</code> の使用</h3>
<pre class="brush: 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>
</pre>
<pre class="brush: js">var el = document.getElementById('div-02');
el.remove(); // 'div-02' の id を持った div を削除
</pre>
<h3 id="Element.remove_is_unscopable"><code>Element.remove()</code> はスコープ化に非対応</h3>
<p><code>remove()</code> メソッドは <code>with</code> 文によるスコープ化に対応していません。 詳細は {{jsxref("Symbol.unscopables")}} を参照してください。</p>
<pre class="brush: js">with(node) {
remove();
}
// ReferenceError: remove is not defined </pre>
<h2 id="Specifications">仕様書</h2>
{{Specifications}}
<h2 id="Browser_compatibility">ブラウザーの互換性</h2>
<p>{{Compat}}</p>
<h2 id="See_also">関連情報</h2>
<ul>
<li><a href="https://github.com/chenzhenxi/element-remove">ポリフィル</a></li>
</ul>
|