element.setCustomAttribute(name, value)

Set a custom HTML attribute for an element.

Syntax

1element.setCustomAttribute(name: string, value: string): Promise<null>

Parameters

  • name : String - The name of the custom attribute.
  • value : String - The value of the custom attribute

The value of the named custom attribute.

Returns

Promise<null>

A promise that resolves to null

Example

1// Get Selected Element
2const selectedElement = await webflow.getSelectedElement()
3
4if (selectedElement?.customAttributes) {
5
6 // Set Custom Attribute
7 await selectedElement.setCustomAttribute("tooltip", "my tooltip value")
8
9}

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canDesignPrimaryMainCanvasDesign
Built with