2021-10-17 18:26:00 +02:00
|
|
|
---
|
2022-09-29 19:01:10 +02:00
|
|
|
title: Attributes.get()
|
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.get()` method will return the value of attribute stored under
|
|
|
|
`key`, or `false` if it's not set.
|
|
|
|
|
|
|
|
## Signature
|
|
|
|
|
2021-08-25 16:09:31 +02:00
|
|
|
```js
|
|
|
|
string attributes.get(string key)
|
|
|
|
```
|
|
|
|
|
2022-12-14 12:52:37 -08:00
|
|
|
If key has multiple values, they will be joined together in a string, separated by spaces.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 19:01:10 +02:00
|
|
|
## Example
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 19:01:10 +02:00
|
|
|
```js
|
|
|
|
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
|
|
|
const class = attr.get('class')
|
2021-08-25 16:09:31 +02:00
|
|
|
// class now holds: "classA classB"
|
|
|
|
```
|