aboutsummaryrefslogtreecommitdiff
path: root/files/fr/orphaned
diff options
context:
space:
mode:
authorMDN <actions@users.noreply.github.com>2021-04-14 00:11:31 +0000
committerMDN <actions@users.noreply.github.com>2021-04-14 00:11:31 +0000
commitdb26cf86829f9b43d29f18b9bbf197e9e2d55c31 (patch)
tree9e4b1a32107c07b5a6d3d449f9d52f3d645aa87f /files/fr/orphaned
parent2a80998020496995b1eb33e0a2ed024f1708535d (diff)
downloadtranslated-content-db26cf86829f9b43d29f18b9bbf197e9e2d55c31.tar.gz
translated-content-db26cf86829f9b43d29f18b9bbf197e9e2d55c31.tar.bz2
translated-content-db26cf86829f9b43d29f18b9bbf197e9e2d55c31.zip
[CRON] sync translated content
Diffstat (limited to 'files/fr/orphaned')
-rw-r--r--files/fr/orphaned/web/api/parentnode/children/index.html90
1 files changed, 90 insertions, 0 deletions
diff --git a/files/fr/orphaned/web/api/parentnode/children/index.html b/files/fr/orphaned/web/api/parentnode/children/index.html
new file mode 100644
index 0000000000..7fed7973ec
--- /dev/null
+++ b/files/fr/orphaned/web/api/parentnode/children/index.html
@@ -0,0 +1,90 @@
+---
+title: ParentNode.children
+slug: orphaned/Web/API/ParentNode/children
+tags:
+ - API
+ - DOM
+ - Noeuds
+ - Propriétés
+ - parent
+translation_of: Web/API/ParentNode/children
+original_slug: 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">&lt;</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 &amp; DocumentFragment pour IE9 &amp; 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">&amp;&amp;</span>
+ constructeur<span class="punctuation token">.</span>prototype <span class="operator token">&amp;&amp;</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>