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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
---
title: ChildNode.remove()
slug: Web/API/ChildNode/remove
translation_of: Web/API/ChildNode/remove
---
<div>{{APIRef("DOM")}}</div>
<p>Metoda <code><strong>ChildNode.remove()</strong></code> usuwa obiekt z drzewa, do którego należy.</p>
<h2 id="Składnia">Składnia</h2>
<pre class="syntaxbox"><em>node</em>.remove();
</pre>
<h2 id="Przykład">Przykład</h2>
<h3 id="Użycie_remove()">Użycie <code>remove()</code></h3>
<pre class="brush: html"><div id="div-01">To jest div-01</div>
<div id="div-02">To jest div-02</div>
<div id="div-03">To jest div-03</div>
</pre>
<pre class="brush: js">var el = document.getElementById('div-02');
el.remove(); // Usuwa div z ID 'div-02'
</pre>
<h3 id="ChildNode.remove()_jest_poza_zakresem"><code>ChildNode.remove()</code> jest poza zakresem</h3>
<p>Metoda <code>remove()</code> nie wchodzi w zakres wyrażenia <code>with</code>. Zobacz {{jsxref("Symbol.unscopables")}}, aby uzyskać więcej informacji.</p>
<pre class="brush: js">with(node) {
remove();
}
// ReferenceError: remove is not defined </pre>
<h2 id="Polyfill">Polyfill</h2>
<p>Można utworzyć polyfill metody <code>remove()</code> w Internet Explorer 9 (lub wyższej wersji) za pomocą następującego kodu: </p>
<pre class="brush: js">// from:https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md
(function (arr) {
arr.forEach(function (item) {
if (item.hasOwnProperty('remove')) {
return;
}
Object.defineProperty(item, 'remove', {
configurable: true,
enumerable: true,
writable: true,
value: function remove() {
this.parentNode.removeChild(this);
}
});
});
})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);</pre>
<h2 id="Specyfikacje">Specyfikacje</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('DOM WHATWG', '#dom-childnode-remove', 'ChildNode.remove')}}</td>
<td>{{Spec2('DOM WHATWG')}}</td>
<td>Initial definition.</td>
</tr>
<tr>
<td>{{SpecName('DOM4', '#dom-childnode-remove', 'ChildNode.remove')}}</td>
<td>{{Spec2('DOM4')}}</td>
<td> </td>
</tr>
</tbody>
</table>
<h2 id="Kompatybilność_z_przeglądarkami">Kompatybilność z przeglądarkami</h2>
<div>{{Compat("api.ChildNode.remove")}}</div>
<h2 id="Zobacz_również">Zobacz również</h2>
<ul>
<li>The {{domxref("ChildNode")}} pure interface.</li>
<li>
<div class="syntaxbox">Object types implementing this pure interface: {{domxref("CharacterData")}}, {{domxref("Element")}}, and {{domxref("DocumentType")}}.</div>
</li>
</ul>
|