aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/document/createattribute/index.md
diff options
context:
space:
mode:
authorjulieng <julien.gattelier@gmail.com>2021-10-02 17:20:14 +0200
committerSphinxKnight <SphinxKnight@users.noreply.github.com>2021-10-02 17:30:20 +0200
commitc05efa8d7ae464235cf83d7c0956e42dc6974103 (patch)
tree6ea911b2f2010f63a026de6bb7a1a51e7690a7e1 /files/fr/web/api/document/createattribute/index.md
parent13a5e017558b248ee1647d4a5825f183b51f09ad (diff)
downloadtranslated-content-c05efa8d7ae464235cf83d7c0956e42dc6974103.tar.gz
translated-content-c05efa8d7ae464235cf83d7c0956e42dc6974103.tar.bz2
translated-content-c05efa8d7ae464235cf83d7c0956e42dc6974103.zip
move *.html to *.md
Diffstat (limited to 'files/fr/web/api/document/createattribute/index.md')
-rw-r--r--files/fr/web/api/document/createattribute/index.md91
1 files changed, 91 insertions, 0 deletions
diff --git a/files/fr/web/api/document/createattribute/index.md b/files/fr/web/api/document/createattribute/index.md
new file mode 100644
index 0000000000..bfec33bfa2
--- /dev/null
+++ b/files/fr/web/api/document/createattribute/index.md
@@ -0,0 +1,91 @@
+---
+title: document.createAttribute
+slug: Web/API/Document/createAttribute
+tags:
+ - API
+ - DOM
+ - Méthodes
+ - Reference
+translation_of: Web/API/Document/createAttribute
+---
+<p>{{ApiRef("DOM")}}</p>
+
+<p>La méthode <code><strong>Document.createAttribute()</strong></code> crée un nouveau nœud d'attribut et le renvoie. L'objet a créé un noeud implémentant l'interface {{domxref("Attr")}}. Le DOM n'impose pas le type d'attribut à ajouter à un élément particulier de cette manière. </p>
+
+<div class="note">
+<p><strong>Note :</strong> La chaîne de caractères donnée dans le paramètre est convertie en minuscules.</p>
+</div>
+
+<h2 id="Syntaxe">Syntaxe</h2>
+
+<pre class="eval"><em>attribut</em> = document.createAttribute(nom)
+</pre>
+
+<h3 id="Param.C3.A8tres">Paramètres</h3>
+
+<ul>
+ <li><code>nom</code> est une chaîne de caractères contenant le nom de l'attribut.</li>
+</ul>
+
+<h3 id="Valeur_de_retour">Valeur de retour</h3>
+
+<p>Un nœud {{domxref("Attr")}}.</p>
+
+<h3 id="Exceptions_levées">Exceptions levées</h3>
+
+<ul>
+ <li><code>INVALID_CHARACTER_ERR</code>  si le paramètre contient un caractère invalide pour un attribut XML.</li>
+</ul>
+
+<h2 id="Exemples">Exemples</h2>
+
+
+<pre class="brush:js">var node = document.getElementById("div1");
+var a = document.createAttribute("my_attrib");
+a.value = "newVal";
+node.setAttributeNode(a);
+console.log(node.getAttribute("my_attrib")); // "newVal"
+</pre>
+<h2 id="Spécifications">Spécifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Spécification</th>
+ <th scope="col">État</th>
+ <th scope="col">Commentaires</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('DOM WHATWG','#dom-document-createattribute','Document.createAttribute()')}}</td>
+ <td>{{Spec2("DOM WHATWG")}}</td>
+ <td> Comportement précis avec des caractères majuscules. </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM3 Core','core.html#ID-1084891198','Document.createAttribute()')}}</td>
+ <td>{{Spec2('DOM3 Core')}}</td>
+ <td>Pas de modification.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM2 Core','core.html#ID-1084891198','Document.createAttribute()')}}</td>
+ <td>{{Spec2('DOM2 Core')}}</td>
+ <td>Pas de modification.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM1','level-one-core.html#ID-1084891198','Document.createAttribute()')}}</td>
+ <td>{{Spec2('DOM1')}}</td>
+ <td>Définition initiale.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>
+
+<p>{{Compat("api.Document.createAttribute")}}</p>
+
+<h2 id="Voir_aussi">Voir aussi</h2>
+
+<ul>
+ <li>{{domxref("Document.createElement()")}}</li>
+</ul>