aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/api/document/createattribute/index.html
blob: 97cbba7120471cef4d7211dc61213e9687fbc540 (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
---
title: Document.createAttribute()
slug: Web/API/Document/createAttribute
translation_of: Web/API/Document/createAttribute
---
<div>{{ ApiRef("DOM") }}</div>

<p>Метод <code><strong>Document.createAttribute()</strong></code> создает новый атрибут узла и возвращает его.  Созданный объект узла реализует {{domxref("Attr")}} интерфейс . <span style='background-color: #f5f5f5; color: #333333; display: inline !important; float: none; font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; font-size: 16px; font-style: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal;'>DOM не указывает, какие атрибуты могут быть добавлены к определенному элементу таким способом.</span></p>

<div class="note">
<p>Строка, заданная в параметре, преобразуется в нижний регистр.</p>
</div>

<h2 id="Syntax" name="Syntax">Syntax</h2>

<pre class="syntaxbox"><em>attribute</em> = document.createAttribute(name)
</pre>

<h3 id="Parameters" name="Parameters">Parameters</h3>

<ul>
 <li><code>name</code> строка, содержащая имя атрибута.</li>
</ul>

<h3 id="Return_value">Return value</h3>

<p>A {{domxref("Attr")}} node.</p>

<h3 id="Exceptions">Exceptions</h3>

<ul>
 <li><code>INVALID_CHARACTER_ERR</code> если параметр содержит недопустимые символы для атрибута XML.</li>
</ul>

<h2 id="Example" name="Example">Example</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="Specification" name="Specification">Спецификации</h2>

<table class="spectable standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('DOM WHATWG','#dom-document-createattribute','Document.createAttribute()')}}</td>
   <td>{{Spec2("DOM WHATWG")}}</td>
   <td>Точное поведение с прописными символами</td>
  </tr>
  <tr>
   <td>{{SpecName('DOM3 Core','core.html#ID-1084891198','Document.createAttribute()')}}</td>
   <td>{{Spec2('DOM3 Core')}}</td>
   <td>No change.</td>
  </tr>
  <tr>
   <td>{{SpecName('DOM2 Core','core.html#ID-1084891198','Document.createAttribute()')}}</td>
   <td>{{Spec2('DOM2 Core')}}</td>
   <td>No change.</td>
  </tr>
  <tr>
   <td>{{SpecName('DOM1','level-one-core.html#ID-1084891198','Document.createAttribute()')}}</td>
   <td>{{Spec2('DOM1')}}</td>
   <td>Первоначальное определение.</td>
  </tr>
 </tbody>
</table>

<h2 id="Совместимость_с_браузерами">Совместимость с браузерами</h2>



<p>{{Compat("api.Document.createAttribute")}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{domxref("Document.createElement()")}}</li>
</ul>