diff options
Diffstat (limited to 'files/fr/web/api/node/issamenode')
| -rw-r--r-- | files/fr/web/api/node/issamenode/index.html | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/files/fr/web/api/node/issamenode/index.html b/files/fr/web/api/node/issamenode/index.html new file mode 100644 index 0000000000..5ed912e638 --- /dev/null +++ b/files/fr/web/api/node/issamenode/index.html @@ -0,0 +1,151 @@ +--- +title: Node.isSameNode() +slug: Web/API/Node/isSameNode +tags: + - API + - DOM + - Méthodes + - Noeuds +translation_of: Web/API/Node/isSameNode +--- +<div>{{APIRef("DOM")}}</div> + +<p>La méthode <code><strong>Node.isSameNode()</strong></code> teste si deux noeuds sont identiques, c'est-à-dire, s'ils font référence au même objet.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox">var <em>isSameNode</em> = <em>node</em>.isSameNode(<em>other</em>); +</pre> + +<h3 id="Paramètres">Paramètres</h3> + +<ul> + <li><code>other</code> Le {{domxref("Node")}} à tester.</li> +</ul> + +<h2 id="Exemple">Exemple</h2> + +<p>Dans cet exemple, nous créons 3 blocs {{HTMLElement("div")}}. Le premier et le troisième ont les mêmes contenus et attributs, alors que le second est différent. Ensuite, nous exécutons du JavaScript pour comparer les nœuds en utilisant <code>isSameNode()</code> et sortons les résultats.</p> + +<h3 id="HTML">HTML</h3> + +<pre class="brush: html"><div>This is the first element.</div> +<div>This is the second element.</div> +<div>This is the first element.</div> + +<p id="output"></p></pre> + +<div class="hidden"> +<h3 id="CSS">CSS</h3> + +<pre class="brush: css">#output { + width: 440px; + border: 2px solid black; + border-radius: 5px; + padding: 10px; + margin-top: 20px; + display: block; +}</pre> +</div> + +<h3 id="JavaScript">JavaScript</h3> + +<pre class="brush: js">let output = document.getElementById("output"); +let divList = document.getElementsByTagName("div"); + +output.innerHTML += "div 0 same as div 0: " + divList[0].isSameNode(divList[0]) + "<br/>"; +output.innerHTML += "div 0 same as div 1: " + divList[0].isSameNode(divList[1]) + "<br/>"; +output.innerHTML += "div 0 same as div 2: " + divList[0].isSameNode(divList[2]) + "<br/>"; +</pre> + +<h3 id="Résultats">Résultats</h3> + +<p>{{ EmbedLiveSample('Example', 480) }}</p> + +<h2 id="Spécifications">Spécifications</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Spécification</th> + <th scope="col">Statut</th> + <th scope="col">Commentaire</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('DOM WHATWG', '#interface-node', 'Node')}}</td> + <td>{{Spec2('DOM WHATWG')}}</td> + <td>Pas de changement (a été longtemps retiré).</td> + </tr> + <tr> + <td>{{SpecName('DOM3 Core', 'core.html#Node3-isSameNode', 'Node.isSameNode()')}}</td> + <td>{{Spec2('DOM3 Core')}}</td> + <td>Définition initiale</td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2> + +<p>{{CompatibilityTable}}</p> + +<div id="compat-desktop"> +<table class="compat-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>Basic support</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoDesktop("1.0")}}<br> + Removed in {{CompatGeckoDesktop("10")}}<br> + Readded in {{CompatGeckoDesktop("48")}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-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>Basic support</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoMobile("1.0")}}<br> + Removed in {{CompatGeckoMobile("10")}}<br> + Readded in {{CompatGeckoMobile("48")}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="Voir_aussi">Voir aussi</h2> + +<ul> + <li>{{domxref("Node.isEqualNode()")}}</li> +</ul> |
