setAttribute( )
Sets an HTML attribute on the custom element's DOM node.
We can use setAttribute()
to affect the custom element's definition and behavior. Consider setAttribute()
a way for Velo to pass information to the custom element based on the context of the site.
Attributes can either be set:
- Using this API with
setAttribute()
. - In the Editor, by clicking the custom element's Set Attribute button, without any coding. Tip: Set attributes using the Editor if you would like to share the element with other designers that don't code.
Each setAttribute()
function sets one attribute at a time using a key-value pair. Use multiple setAttribute()
functions to set more than one attribute.
If the custom element does not yet have the attribute, setAttribute()
creates it.
Method Declaration
Copy
Method Parameters
keystringRequired
The name of the attribute. Use lowercase characters.
valueunionRequired
The value of the attribute.
Was this helpful?
Yes
No