Set Custom Attribute

element.setCustomAttribute(name, value)

Set an attribute on an element.

Previously, this method set only custom HTML attributes on an element, but now it can set any attributes.

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