https://support.wix.com/en/article/wix-code-tutorial-creating-a-show-more-link In preview shows the correct 40 characters and ... with show more button until I add the if else statement... what am I doing wrong?
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("#EnergyProfile").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("#EnergyProfile").text = shortText; // check the contents of the text element if ($w("#EnergyProfile").text === shortText) { // if currently displaying short text, display the full text $w("#EnergyProfile").text = fullText; $w("#EnergyProfileButton").label = "Show less"; } else { // if currently displaying full text, display the short text $w("#EnergyProfile").text = shortText; $w("#EnergyProfileButton").label = "Show more"; } }); export function showMore_click(event) { // display the full text $w("#EnergyProfile").text = fullText; // collapse the button $w("#EnergyProfileButton").collapse(); }
I can leave it expanded but how can I get the strip to expand with it...so that it doesn't leave all of the extra space when collapsed?
Hi,
I'm not sure I understand the problem, can you provide screenshots of the problem?