Hi, I have been updating my site and on the home page there is a huge section of text at that i wanted to get rid of, turn it into a “show more show less” option.
I was successful in doing this however when someone searches and lands on my home page it comes out at scattered?
It seems to be a connection to the coding or text as when I deleted the code & show more button it runs like normal.
(Visit Us, Contact Us, Tell Us, Is the footer - its completely jumbled up)
(How it looks without the code for the text show more show less)
This is the code I have used:
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 = 759;
// read the full text and store it in the fullText variable
fullText = $w(“#hometext”).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(“#hometext”).text = shortText;
});
export function button7_click_1(event) {
// check the contents of the text element
if ($w(“#hometext”).text === shortText) {
// if currently displaying short text, display the full text
$w(“#hometext”).text = fullText;
$w(“#button7”).label = “Show less”;
} else {
// if currently displaying full text, display the short text
$w(“#hometext”).text = shortText;
$w(“#button7”).label = “Show more”;
}
}
Any help is very much appreciated! Thank you
#wixcode
Purslowe Web Design