Skip to content

Commit

Permalink
[ru] update Web/API/Document/createAttribute translation (#23371)
Browse files Browse the repository at this point in the history
* [ru] update 'Web/API/Document/createAttribute' translation

* Update files/ru/web/api/document/createattribute/index.md

Co-authored-by: Artem Shibakov <[email protected]>

---------

Co-authored-by: Artem Shibakov <[email protected]>
  • Loading branch information
leon-win and saionaro authored Oct 2, 2024
1 parent b2dbc9d commit 5f76d0d
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions files/ru/web/api/document/createattribute/index.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
---
title: Document.createAttribute()
title: "Document: метод createAttribute()"
slug: Web/API/Document/createAttribute
l10n:
sourceCommit: be8f7f155a48e11b30c240f8731afb1845f85378
---

{{APIRef("DOM")}}
{{ ApiRef("DOM") }}

Метод **`Document.createAttribute()`** создаёт новый атрибут узла и возвращает его. Созданный объект узла реализует {{domxref("Attr")}} интерфейс . DOM не указывает, какие атрибуты могут быть добавлены к определённому элементу таким способом.
Метод **`Document.createAttribute()`** создаёт новый атрибут и возвращает его. Созданный объект является узлом и реализует интерфейс {{domxref("Attr")}}. DOM не накладывает ограничений на тип атрибутов, которые могут быть добавлены к определённому элементу таким способом.

> [!NOTE]
> Строка, заданная в параметре, преобразуется в нижний регистр.
## Syntax
## Синтаксис

```
attribute = document.createAttribute(name)
```js-nolint
createAttribute(name)
```

### Parameters
### Параметры

- `name` строка, содержащая имя атрибута.
- `name`
- : строка, содержащая имя атрибута.

### Return value
### Возвращаемое значение

A {{domxref("Attr")}} node.
Узел {{domxref("Attr")}}.

### Exceptions
### Исключения

- `INVALID_CHARACTER_ERR` если параметр содержит недопустимые символы для атрибута XML.
- `InvalidCharacterError` {{domxref("DOMException")}}
- : Вызывается если значение [`name`](#name) не является корректным [именем XML](https://www.w3.org/TR/REC-xml/#dt-name) (например, начинается с цифры, дефиса или точки, или содержит символы, отличные от букв и цифр, подчёркиваний, дефисов и точек).

## Example
## Примеры

```js
var node = document.getElementById("div1");
var a = document.createAttribute("my_attrib");
const node = document.getElementById("div1");
const a = document.createAttribute("my_attrib");
a.value = "newVal";
node.setAttributeNode(a);
console.log(node.getAttribute("my_attrib")); // "newVal"
Expand All @@ -48,4 +52,7 @@ console.log(node.getAttribute("my_attrib")); // "newVal"

## Смотрите также

- {{domxref("Document.createAttributeNS()")}}
- {{domxref("Document.createElement()")}}
- {{domxref("Element.setAttribute()")}}
- {{domxref("Element.setAttributeNode()")}}

0 comments on commit 5f76d0d

Please sign in to comment.