Hello,
I have been reviewing the documentation on String Elements, which mentions that one can retrieve the content of the elements. However, when I attempt to use .getText(), I encounter an error indicating that this function does not exist on the element type.
Upon checking all available methods and keys for String Elements, I found the following list:
[
"id", "detach", "destroy", "configurable", "save", "customAttributes",
"getCustomAttribute", "setCustomAttribute", "getAllCustomAttributes",
"removeCustomAttribute", "domId", "getDomId", "setDomId", "styles",
"getStyles", "setStyles", "children", "getChildren", "setChildren",
"textContent", "setTextContent", "type", "plugin", "constructor",
"__defineGetter__", "__defineSetter__", "hasOwnProperty",
"__lookupGetter__", "__lookupSetter__", "isPrototypeOf",
"propertyIsEnumerable", "toString", "valueOf", "__proto__",
"toLocaleString"
]
It appears that the .getText() function is not included in this list, despite being mentioned in the documentation. Has anyone else encountered this discrepancy?
Clarification: I’m selecting the current element and I’m trying to call the method to that, so on a text element.
Here a code example:
const element = await webflow.getSelectedElement()
if(element.textContent) {
const text = element.getText() // throws function is not found error
console.log(text)
}