I have coded the homepage to create a text section to expand. However, when I preview the site, only the expanded version shows rather than my limit of 200 characters. I’m new to coding so I have no idea what is wrong, even after reading multiple posts in the forum. Also, when I preview, my text design has changed even though it looks the same as designed in editor. My code is below.
let fullText; // variable to hold the full text
let shortText; // variable to hold the short version of the text
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
$w.onReady( function () {
// how many characters to include in the shortened version
const shortTextLength = 210;
// read the full text and store it in the fullText variable
fullText = $w(‘#text4’).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 the text element to be the short text
$w(‘#text4’).text = shortText;
// display the full text
$w(‘#text4’).text = fullText;
//TODO: write your page related code here…
});
export function button2_click(event) {
// display the full text
$w(“#text4”).text = fullText;
// collapse the button
$w(“#button2”).collapse();
//Add your code for this event here:
}