Get Custom Attribute

element.getCustomAttribute(name)

Get custom HTML attributes for an element by name.

Syntax

element.getCustomAttribute(name: string):Promise<null | string>

Parameters

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

Returns

Promise<String>

A Promise that resolves to the value of the named custom attribute.

Example

// Get Selected Element
const selectedElement = await webflow.getSelectedElement()
if (selectedElement?.customAttributes) {
// Get Custom Attribute by Name
const customAttribute = await selectedElement.getCustomAttribute('tooltip')
console.log(customAttribute)
}

Designer Ability

Checks for authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAny