From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/fr/web/api/node/haschildnodes/index.html | 122 +++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 files/fr/web/api/node/haschildnodes/index.html (limited to 'files/fr/web/api/node/haschildnodes') diff --git a/files/fr/web/api/node/haschildnodes/index.html b/files/fr/web/api/node/haschildnodes/index.html new file mode 100644 index 0000000000..93d5f636aa --- /dev/null +++ b/files/fr/web/api/node/haschildnodes/index.html @@ -0,0 +1,122 @@ +--- +title: element.hasChildNodes +slug: Web/API/Node/hasChildNodes +tags: + - API + - DOM + - Enfant + - Méthodes + - Noeuds +translation_of: Web/API/Node/hasChildNodes +--- +

{{APIRef("DOM")}}

+ +

La méthode Node.hasChildNodes() renvoie une valeur booléenne indiquant si le {{domxref("Node","noeud")}} actuel possède des nœuds enfants ou non.

+ +

Syntaxe

+ +
resultat =element.hasChildNodes();
+
+ +

Exemple

+ +

L'exemple suivant supprime le premier noeud enfant à l'intérieur de l'élément avec l'identifiant "foo" si "foo" a des noeuds enfant.

+ +
var foo = document.getElementById("foo");
+if (foo.hasChildNodes()) {
+    // faire quelque chose avec les 'foo.childNodes'
+}
+ +

Polyfill

+ +

 

+ +
;(function(prototype) {
+    prototype.hasChildNodes = prototype.hasChildNodes || function() {
+        return !!this.firstChild;
+    }
+})(Node.prototype);
+ +

Résumé

+ +

Il y a différentes façons de déterminer si le noeud a un noeud enfant :

+ + + +

Spécification

+ + + +

Compatibilité des navigateurs

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
FonctionnalitéChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}7.0{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FonctionnalitéAndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +

 

+ +

Voir aussi

+ + + +
 
+ +

 

-- cgit v1.2.3-54-g00ecf