diff options
author | MDN <actions@users.noreply.github.com> | 2021-04-14 00:11:31 +0000 |
---|---|---|
committer | MDN <actions@users.noreply.github.com> | 2021-04-14 00:11:31 +0000 |
commit | db26cf86829f9b43d29f18b9bbf197e9e2d55c31 (patch) | |
tree | 9e4b1a32107c07b5a6d3d449f9d52f3d645aa87f /files/fr/web | |
parent | 2a80998020496995b1eb33e0a2ed024f1708535d (diff) | |
download | translated-content-db26cf86829f9b43d29f18b9bbf197e9e2d55c31.tar.gz translated-content-db26cf86829f9b43d29f18b9bbf197e9e2d55c31.tar.bz2 translated-content-db26cf86829f9b43d29f18b9bbf197e9e2d55c31.zip |
[CRON] sync translated content
Diffstat (limited to 'files/fr/web')
-rw-r--r-- | files/fr/web/api/parentnode/children/index.html | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/files/fr/web/api/parentnode/children/index.html b/files/fr/web/api/parentnode/children/index.html deleted file mode 100644 index 52c529a1b8..0000000000 --- a/files/fr/web/api/parentnode/children/index.html +++ /dev/null @@ -1,89 +0,0 @@ ---- -title: ParentNode.children -slug: Web/API/ParentNode/children -tags: - - API - - DOM - - Noeuds - - Propriétés - - parent -translation_of: Web/API/ParentNode/children ---- -<p>{{ APIRef("DOM") }}</p> - -<p>La propriété <code><strong>children</strong></code> de {{domxref("ParentNode")}} est une propriété en lecture seule qui renvoie une {{domxref("HTMLCollection")}} directe contenant tous les enfants {{domxref("Element","éléments")}} du noeud sur lequel elle a été appelée.</p> - -<h2 id="Syntaxe">Syntaxe</h2> - -<pre class="syntaxbox">var <em>children</em> = <em>node</em>.children;</pre> - -<h3 id="Valeur">Valeur</h3> - -<p>Une {{ domxref("HTMLCollection") }}, qui est une collection directe et ordonnée des éléments DOM qui sont enfants du <em><code>node</code></em> (<em>noeud</em>). Vous pouvez accéder aux noeuds enfants individuellement en utilisant la méthode {{domxref("HTMLCollection.item", "item()")}} (<em>élément</em>) sur la collection ou en utilisant la notation de type tableau (<em>array</em>) de JavaScript.</p> - -<p>S'il n'y a pas d'éléments enfants, alors <code>children</code> est une liste vide et a une <code>length</code> (<em>longueur</em>) de <code>0</code>.</p> - -<h2 id="Exemple">Exemple</h2> - -<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">var</span> machin <span class="operator token">=</span> document<span class="punctuation token">.</span><span class="function token">getElementById</span><span class="punctuation token">(</span><span class="string token">'machin'</span><span class="punctuation token">)</span><span class="punctuation token">;</span> -<span class="keyword token">for</span> <span class="punctuation token">(</span><span class="keyword token">var</span> i <span class="operator token">=</span> <span class="number token">0</span><span class="punctuation token">;</span> i <span class="operator token"><</span> machin<span class="punctuation token">.</span>children<span class="punctuation token">.</span>length<span class="punctuation token">;</span> i<span class="operator token">++</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> - console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>machin<span class="punctuation token">.</span>children<span class="punctuation token">[</span>i<span class="punctuation token">]</span><span class="punctuation token">.</span>tagName<span class="punctuation token">)</span><span class="punctuation token">;</span> -<span class="punctuation token">}</span></code></pre> - -<h2 id="Polyfill">Polyfill</h2> - -<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="comment token">// Réécrit le prototype 'children' natif.</span> -<span class="comment token">// Ajoute le support de Document & DocumentFragment pour IE9 & Safari.</span> -<span class="comment token">// Renvoie un tableau (<em>array</em>) au lieu d'une HTMLCollection.</span> -<span class="punctuation token">;</span><span class="punctuation token">(</span><span class="keyword token">function</span><span class="punctuation token">(</span>constructeur<span class="punctuation token">)</span> <span class="punctuation token">{</span> - <span class="keyword token">if</span> <span class="punctuation token">(</span>constructeur <span class="operator token">&&</span> - constructeur<span class="punctuation token">.</span>prototype <span class="operator token">&&</span> - constructeur<span class="punctuation token">.</span>prototype<span class="punctuation token">.</span>children <span class="operator token">==</span> <span class="keyword token">null</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> - Object<span class="punctuation token">.</span><span class="function token">defineProperty</span><span class="punctuation token">(</span>constructeur<span class="punctuation token">.</span>prototype<span class="punctuation token">,</span> <span class="string token">'children'</span><span class="punctuation token">,</span> <span class="punctuation token">{</span> - <span class="keyword token">get</span><span class="punctuation token">:</span> <span class="keyword token">function</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> - <span class="keyword token">var</span> i <span class="operator token">=</span> <span class="number token">0</span><span class="punctuation token">,</span> noeud<span class="punctuation token">,</span> noeuds <span class="operator token">=</span> <span class="keyword token">this</span><span class="punctuation token">.</span>childNodes<span class="punctuation token">,</span> children <span class="operator token">=</span> <span class="punctuation token">[</span><span class="punctuation token">]</span><span class="punctuation token">;</span> - <span class="keyword token">while</span> <span class="punctuation token">(</span>noeud <span class="operator token">=</span> noeuds<span class="punctuation token">[</span>i<span class="operator token">++</span><span class="punctuation token">]</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> - <span class="keyword token">if</span> <span class="punctuation token">(</span>noeud<span class="punctuation token">.</span>nodeType <span class="operator token">===</span> <span class="number token">1</span><span class="punctuation token">)</span> <span class="punctuation token">{</span> - children<span class="punctuation token">.</span><span class="function token">push</span><span class="punctuation token">(</span>noeud<span class="punctuation token">)</span><span class="punctuation token">;</span> - <span class="punctuation token">}</span> - <span class="punctuation token">}</span> - <span class="keyword token">return</span> children<span class="punctuation token">;</span> - <span class="punctuation token">}</span> - <span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span> - <span class="punctuation token">}</span> -<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">(</span>window<span class="punctuation token">.</span>Node <span class="operator token">||</span> window<span class="punctuation token">.</span>Element<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> - -<h2 id="Spécification">Spécification</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">Spécification</th> - <th scope="col">Statut</th> - <th scope="col">Commentaire</th> - </tr> - <tr> - <td>{{SpecName('DOM WHATWG', '#dom-parentnode-children', 'ParentNode.children')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Définition initiale.</td> - </tr> - </tbody> -</table> - -<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2> - - - -<p>{{Compat("api.ParentNode.children")}}</p> - -<h2 id="Voir_aussi">Voir aussi</h2> - -<ul> - <li>Les interfaces {{domxref("ParentNode")}} et{{domxref("ChildNode")}}.</li> - <li> - <div class="syntaxbox">Les types d'objets implémentant cette interface : {{domxref("Document")}}, {{domxref("Element")}} et {{domxref("DocumentFragment")}}.</div> - </li> - <li> - <div class="syntaxbox">{{domxref("Node.childNodes")}}</div> - </li> -</ul> |