Element.getAttr method
Element › getAttr
Official
Gets an attribute from the element.Signature:
getAttr(qualifiedName: string): null | stringParameters:
| Parameter | Type | Description |
|---|---|---|
| qualifiedName | string | The name of the attribute to get. |
Returns: null | string — The value of the attribute.
Example:
const element = createEl('p');element.setAttr('data-foo', 'bar');console.log(element.getAttr('data-foo')); // bar