Set Text Content

element.setTextContent(content)

Set text content for an element that supports text content.

Syntax

element.setTextContent(content: string): Promise<null>>

Parameters

  • content: string - Text to add to the element

Returns

Promise<null>

A Promise that resolves to null.

Example

// Get Selected Element
const selectedElement = await Webflow.getSelectedElement()
if (selectedElement?.textContent) {
// Set and print text content
const text = await selectedElement.setTextContent("Lorem Ipsum")
console.log(selectedElement.textContent)
}

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canEditAnyAnyCanvasAny