aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/htmltableelement/insertrow/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/fr/web/api/htmltableelement/insertrow/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/fr/web/api/htmltableelement/insertrow/index.html')
-rw-r--r--files/fr/web/api/htmltableelement/insertrow/index.html152
1 files changed, 152 insertions, 0 deletions
diff --git a/files/fr/web/api/htmltableelement/insertrow/index.html b/files/fr/web/api/htmltableelement/insertrow/index.html
new file mode 100644
index 0000000000..737195cf29
--- /dev/null
+++ b/files/fr/web/api/htmltableelement/insertrow/index.html
@@ -0,0 +1,152 @@
+---
+title: table.insertRow
+slug: Web/API/HTMLTableElement/insertRow
+tags:
+ - API
+ - DOM HTML
+ - HTMLTableElement
+ - Méthode
+ - NeedsMobileBrowserCompatibility
+ - Reference
+translation_of: Web/API/HTMLTableElement/insertRow
+---
+<div>
+<p>{{APIRef("HTML DOM")}}</p>
+
+<p>La méthode <strong><code>HTMLTableElement.insertRow()</code></strong> insère une nouvelle ligne dans la table et retourne une référence à la nouvelle ligne.</p>
+</div>
+
+<h2 id="Syntax" name="Syntax">Syntaxe</h2>
+
+<pre class="syntaxbox">var <em>ligne</em> = <em>HTMLTableElement</em>.insertRow(<em>optionnel indice = -1</em>);</pre>
+
+<ul>
+ <li><a href="/en-US/docs/DOM/HTMLTableElement" title="DOM/HTMLTableElement"><code>HTMLTableElement</code></a> est une référence à un élément table HTML.</li>
+ <li><code>indice</code> est l'indice de ligne de la nouvelle ligne.</li>
+ <li><code>ligne</code> reçoit la référence à la nouvelle ligne. Une référence à un <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableRowElement">HTMLTableRowElement</a>. Si l'indice est -1 ou est égal au nombre de lignes, la ligne est ajoutée comme dernière ligne. Si <code>indice</code> est plus grand que le nombre de lignes, une exception IndexSizeError sera générée. Si indice est omis, sa  valeur sera -1 par défaut.</li>
+ <li>Si une table a plusieurs éléments <code>tbody</code>, par défaut, la nouvelle ligne est ajoutée dans le dernier <code>tbody</code>. Pour insérer la ligne dans un <code>tbody</code> particulier :<br>
+ <code>var <em>tbody_particulier</em></code><code>=document.getElementById(<em>id_tbody</em>);<br>
+ var <em>ligne</em>=tbody_particulier.</code><code>insertRow(<em>indice</em>)</code></li>
+</ul>
+
+<h2 id="Example" name="Example">Exemple</h2>
+
+<pre class="brush:html">&lt;table id="TableA"&gt;
+&lt;tr&gt;
+&lt;td&gt;Ancienne ligne supérieure&lt;/td&gt;
+&lt;/tr&gt;
+&lt;/table&gt;
+&lt;script type="text/javascript"&gt;
+
+function ajouteLigne(tableID) {
+ // Récupération d'une référence à la table
+ var refTable = document.getElementById(tableID);
+
+ // Insère une ligne dans la table à l'indice de ligne 0
+ var nouvelleLigne = refTable.insertRow(0);
+
+ // Insère une cellule dans la ligne à l'indice 0
+ var nouvelleCellule = nouvelleLigne.insertCell(0);
+
+ // Ajoute un nœud texte à la cellule
+ var nouveauTexte = document.createTextNode('Nouvelle ligne supérieure')
+ nouvelleCellule.appendChild(nouveauTexte);
+}
+
+// Appelle ajouteLigne() avec l'ID d'une table
+ajouteLigne('TableA');
+
+&lt;/script&gt;</pre>
+
+<p>Pour être valide dans un document HTML, un élément TR doit avoir au moins un élément TD.</p>
+
+<p>Remarquez que <code>insertRow</code> insère directement la ligne dans la table et renvoie une référence à la nouvelle ligne. La ligne n'a pas besoin d'être ajoutée séparement comme cela aurait été le cas si <code><a href="/en-US/docs/DOM/document.createElement" title="DOM/document.createElement">document.createElement()</a></code> avait été utilisé pour créer un nouvel élement TR.</p>
+
+<h2 id="Spécifications">Spécifications</h2>
+
+<table>
+ <tbody>
+ <tr>
+ <th>Spécification</th>
+ <th>Statut</th>
+ <th>Commentaire</th>
+ </tr>
+ <tr>
+ <td>{{SpecName("HTML WHATWG", "tables.html#dom-table-insertrow", "HTMLTableElement.insertRow()")}}</td>
+ <td>{{Spec2("HTML WHATWG")}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName("DOM2 HTML", "html.html#ID-93995626", "HTMLTableElement.insertRow()")}}</td>
+ <td>{{Spec2("DOM2 HTML")}}</td>
+ <td>Spécifie plus en détail où la ligne est insérée.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName("DOM1", "level-one-html.html#ID-39872903", "HTMLTableElement.insertRow()")}}</td>
+ <td>{{Spec2("DOM1")}}</td>
+ <td>Définition initiale.</td>
+ </tr>
+ </tbody>
+</table>
+
+<p> </p>
+
+<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>
+
+<div>
+<p>{{CompatibilityTable}}</p>
+
+<table>
+ <tbody>
+ <tr>
+ <th>Fonctionnalité</th>
+ <th>Chrome</th>
+ <th>Edge</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Support de base</td>
+ <td>4</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>3<sup>[1]</sup></td>
+ <td>5.5</td>
+ <td>10</td>
+ <td>4</td>
+ </tr>
+ </tbody>
+</table>
+
+<table>
+ <tbody>
+ <tr>
+ <th>Fonctionnalité</th>
+ <th>Android</th>
+ <th>Edge</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Support de base</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>[1] A partir de Gecko 20.0 {{geckoRelease("20.0")}}, l'argument indice a été rendu optionnel et a -1 comme valeur par défaut d'après la spécification HTML.</p>
+</div>
+
+<h2 id="Voir_aussi">Voir aussi</h2>
+
+<ul>
+ <li>{{domxref("HTMLTableRowElement.insertCell()")}}</li>
+</ul>