Set Text

element.setText(text)

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

Syntax

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

Parameters

  • text: string - The new text for your StringElement

Returns

Promise<null>

A Promise that resolves to null.

Example

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

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canEditAnyAnyCanvasAny