2021-10-17 18:26:00 +02:00
|
|
|
---
|
2022-09-29 19:01:10 +02:00
|
|
|
title: Attributes.add()
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 19:01:10 +02:00
|
|
|
The `Attributes.add()` method adds `value` to the attribute identified by
|
|
|
|
`key`.
|
|
|
|
|
|
|
|
## Signature
|
|
|
|
|
2021-08-25 16:09:31 +02:00
|
|
|
```js
|
|
|
|
Attributes attributes.add(string key, string value)
|
|
|
|
```
|
|
|
|
|
2022-09-29 19:01:10 +02:00
|
|
|
## Example
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
```js
|
2022-09-29 19:01:10 +02:00
|
|
|
const attr = new Attributes()
|
|
|
|
.add('class', 'classA')
|
|
|
|
.add('class', 'classB')
|
|
|
|
```
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 19:01:10 +02:00
|
|
|
## Notes
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 19:01:10 +02:00
|
|
|
Adding multiple values to the same key will result in them being joined together
|
|
|
|
(with a space) when rendering.
|