diff options
Diffstat (limited to 'files/fr/web/api/domtokenlist/length/index.html')
| -rw-r--r-- | files/fr/web/api/domtokenlist/length/index.html | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/files/fr/web/api/domtokenlist/length/index.html b/files/fr/web/api/domtokenlist/length/index.html new file mode 100644 index 0000000000..020d7bd7f6 --- /dev/null +++ b/files/fr/web/api/domtokenlist/length/index.html @@ -0,0 +1,68 @@ +--- +title: DOMTokenList.length +slug: Web/API/DOMTokenList/length +tags: + - API + - DOM + - Listes + - Longueur + - Propriétés +translation_of: Web/API/DOMTokenList/length +--- +<p>{{APIRef("DOM")}}</p> + +<p>La propriété en lecture seule <code><strong>length</strong></code> (<em>longueur</em>) de l'interface {{domxref("DOMTokenList")}} est un <code>integer</code> (<em>entier</em>) représentant le nombre d'objets stockés dans la liste.</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox">tokenList.length;</pre> + +<h3 id="Value">Value</h3> + +<p>Un <code>integer</code> (<em>entier</em>).</p> + +<h2 id="Exemples">Exemples</h2> + +<p>Dans l'exemple suivant, nous récupérons la liste des classes définies dans un élément {{htmlelement("span")}} en tant que <code>DOMTokenList</code> en utilisant {{domxref("Element.classList")}}, puis écrivons la longueur (<em>length</em>) de la liste dans le {{domxref("Node.textContent")}} du <code><span></code>.</p> + +<p>D'abord le HTML:</p> + +<pre class="brush: html"><span class="a b c"></span></pre> + +<p>Maintenant le JavaScript:</p> + +<pre class="brush: js">var span = document.querySelector("span"); +var classes = span.classList; +var length = classes.length; + +span.textContent = 'classList length = ' + length; +</pre> + +<p>La sortie ressemble à ceci :</p> + +<p>{{ EmbedLiveSample('Examples', '100%', 60) }}</p> + +<h2 id="Spécifications">Spécifications</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-domtokenlist-length','length')}}</td> + <td>{{Spec2('DOM WHATWG')}}</td> + <td>Définition initiale</td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2> + +<div>{{Compat("api.DOMTokenList.length")}}</div> + +<div id="compat-desktop"> </div> + +<div id="compat-mobile"> </div> |
