top of page
Forum Posts
Chris Black
Apr 07, 2019
In Coding with Velo
Can someone please help me out to make this work? It doesn't show any errors but the button doesn't do anything. The short text displays upon page load, with the button displaying "show more" as intended, but doesn't do anything when you click on it. Here is my code:
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 = 93;
// read the full text and store it in the fullText variable
fullText = $w("#text3").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("#text3").text = shortText;
});
export function button1_click(event) {
//check the contents of the text element
if ($w("#text3").text === shortText) {
// if currently displaying short text, display the full text
$w("#text3").text = fullText;
$w("#button1").label = "Show less";
} else {
// if currently displaying full text, display the short text
$w("#text3").text = shortText;
$w("#button1").label = "Show more";
}
}
0
1
670
Chris Black
More actions
bottom of page