element.setText(text)

Sets the text value on a String element, overwriting any prior text value.

Syntax

1element.setText(text: string): Promise<null>

Parameters

  • text: string - The new text for your StringElement

Returns

Promise<null>

A Promise that resolves to null.

Example

1// Get all elements and find the first StringElement
2const allElements = await webflow.getAllElements();
3const foundElement = allElements.find(el => el.type === "String");
4
5if (foundElement) {
6 // Check that element has the method in order to use it
7 if ('setText' in foundElement) {
8 const elementText = foundElement.setText("Hello Element 🚀"); // Set Text
9 }
10} else {
11 console.log('Element not found on page');
12}

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canEditAnyAnyCanvasAny
Built with