From 156b518735b8da6cc954105b0a1250ca31449381 Mon Sep 17 00:00:00 2001 From: MDN Date: Sat, 22 May 2021 00:42:07 +0000 Subject: [CRON] sync translated content --- .../orphaned/web/api/childnode/remove/index.html | 92 ++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 files/fr/orphaned/web/api/childnode/remove/index.html (limited to 'files/fr/orphaned') diff --git a/files/fr/orphaned/web/api/childnode/remove/index.html b/files/fr/orphaned/web/api/childnode/remove/index.html new file mode 100644 index 0000000000..1faa1703bc --- /dev/null +++ b/files/fr/orphaned/web/api/childnode/remove/index.html @@ -0,0 +1,92 @@ +--- +title: ChildNode.remove() +slug: orphaned/Web/API/ChildNode/remove +tags: + - API + - DOM + - Méthodes + - Noeud Enfant +translation_of: Web/API/ChildNode/remove +original_slug: Web/API/ChildNode/remove +--- +
{{APIRef("DOM")}}
+ +

La méthode ChildNode.remove() retire l'objet de l'arbre auquel il appartient.

+ +

Syntaxe

+ +
node.remove();
+
+ +

Exemple

+ +

Utilisation de la méthode remove()

+ +
<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>
+
+ +
var el = document.getElementById('div-01');
+el.nextElementSibling.remove(); // Retire l'élément div dont l'id est 'div-02'
+ +

ChildNode.remove() est unscopable

+ +

La méthode remove() n'est pas comprise dans une instruction with. Voir {{jsxref("Symbol.unscopables")}} pour plus d'informations.

+ +
with(node) {
+  remove();
+}
+// ReferenceError: remove is not defined (remove n'est pas défini)
+ +

Prothèse d'émulation

+ +

Vous pouvez utiliser une prothèse d'émulation pour la méthode remove() dans Internet Explorer 9 et supérieur avec le code suivant :

+ +
// 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() {
+        if (this.parentNode !== null)
+          this.parentNode.removeChild(this);
+      }
+    });
+  });
+})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);
+ +

Spécifications

+ + + + + + + + + + + + + + +
SpécificationStatutCommentaire
{{SpecName('DOM WHATWG', '#dom-childnode-remove', 'ChildNode.remove')}}{{Spec2('DOM WHATWG')}}Définition initiale
+ +

Compatibilité des navigateurs

+ +
{{Compat("api.ChildNode.remove")}}
+ +

Voir aussi

+ + -- cgit v1.2.3-54-g00ecf