element.setTextContent(content)

Set text content for an element that supports text content.

Syntax

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

Parameters

  • content: string - Text to add to the element

Returns

Promise<null>

A Promise that resolves to null.

Example

1// Get Selected Element
2const selectedElement = await Webflow.getSelectedElement()
3
4if (selectedElement?.textContent) {
5
6 // Set and print text content
7 const text = await selectedElement.setTextContent("Lorem Ipsum")
8 console.log(selectedElement.textContent)
9
10}

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canEditAnyAnyCanvasAny
Built with