Designer API
Control the Webflow Designer
element.getText()
Retrieves the text value from a String element.
1element.getText(): Promise<null | string>
Promise<string>
string
A Promise that always resolves to a String value, which is the text content of the string element.
1// Get Selected Element2const selectedElement = await webflow.getSelectedElement();34if (selectedElement?.textContent && selectedElement?.children) {56 // Get Child Elements7 const children = await selectedElement.getChildren();89 // Filter string elements from children10 const strings = children.filter(child => child.type === "String");1112 // Initialize an array to hold text content13 let textContent = [];1415 // Loop over string elements to get text16 for (const myString of strings) {17 if (myString.type === "String") {18 const text = await myString.getText();19 textContent.push(text);20 }21 }2223 // Print text24 console.log(textContent);25}
Checks for authorization only