I am following the Wix’s tutorial: https://support.wix.com/en/article/creating-an-expandable-text-box-with-a-show-more-link-using-wix-code. My amended version is written below:
let fullText; // variable to hold the full text
let shortText; // variable to hold the short version of the text
$w.onReady(function () {
// how many characters to include in the shortened version
const shortTextLength = 40;
// read the full text and store it in the fullText variable
fullText = $w("#text22").text;
// // grab the number of characters defined in shortTextLength and store them in the shortText variable
shortText = fullText.substr(0, shortTextLength) + "...";
// set the contents of #text46 to be the short text
$w("#text22").text = shortText;
});
However, I am constantly receiving an error message: 'TypeError: Cannot read property ‘substr’ of undefined ’
How can I solve this?
Thanks
Cheers,
Axel