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:

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