aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/attr/localname/index.html
blob: 11e306eac5b7a57f8c5139694f50bb1998340e8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
---
title: Attr.localName
slug: Web/API/Attr/localName
tags:
  - API
  - DOM
  - Propriétés
  - Reference
translation_of: Web/API/Attr/localName
---
<div>{{APIRef("DOM")}}</div>

<p>La propriété <code><strong>Attr.localName</strong></code>, en lecture seule, renvoie la partie locale du nom qualifié d'un élément.</p>

<div class="note">
<p>Avant DOM4, cette API était définie dans l'interface {{domxref("Node")}}.</p>
</div>

<h2 id="Syntaxe">Syntaxe</h2>

<pre class="syntaxbox"><var>name</var> = <var>attribute</var>.localName
</pre>

<h3 id="Valeur_renvoyée">Valeur renvoyée</h3>

<p>Une {{domxref("DOMString")}} <em>(chaîne de caractères)</em> qui représente la partie locale du nom qualifié de l'élément.</p>

<h2 id="Exemple">Exemple</h2>

<p>Cet exemple affiche "id" dans une  fenêtre d'alerte.</p>

<h3 id="Contenu_HTML">Contenu HTML</h3>

<pre class="brush: html">&lt;button id="exemple"&gt;Clique ici&lt;/button&gt;</pre>

<h3 id="Contenu_JavaScript">Contenu JavaScript</h3>

<pre class="brush: js">const element = document.querySelector("#exemple");
element.addEventListener("click", function() {
  const attribute = element.attributes[0];
  alert(attribute.localName);
});
</pre>

<p>{{ EmbedLiveSample('Exemple','100%',30) }}</p>

<h2 id="Notes">Notes</h2>

<p>Le nom local d'un attribut est la partie du nom qualifié de cet attribut avant les deux points. les noms qualifiés sont utilisés en XML, dans les espaces de nom de certains documents.</p>

<div class="note">
<p><strong>Note :</strong> dans {{Gecko("1.9.2")}} et avant, cette propriété renvoie le nom en majuscule pour les attributs HTML du  DOM HTML (contrairement aux atttributs XHTML ). Dans les versions plus récentes, en accord avec HTML5, cette propriété renvoie la casse correspondante au DOM utilisé, c'est-à-dire en minuscule pour les attributs du DOM XHTMl et du DOM HTML.</p>
</div>

<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('DOM4', '#interface-attr', 'Attr.localName')}}</td>
   <td>{{Spec2('DOM4')}}</td>
   <td>première définition</td>
  </tr>
 </tbody>
</table>

<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<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>46.0<sup>[1]</sup></td>
   <td>17</td>
   <td>{{CompatGeckoDesktop("48.0")}}<sup>[1]</sup></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatVersionUnknown}}</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 Mobile</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>17</td>
   <td>{{CompatGeckoMobile("48.0")}}<sup>[1]</sup></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>
</div>

<p>[1] Cette API était disponible précédemment au travers de l'API {{domxref("Node")}}.</p>

<h2 id="Voir_également">Voir également</h2>

<ul>
 <li>{{domxref("Attr.namespaceURI")}}</li>
 <li>{{domxref("Attr.prefix")}}</li>
 <li>{{domxref("Element.localName")}}</li>
 <li>{{domxref("Node.localName")}}</li>
</ul>