# Expandable text - Toggle button problem

**URL:** <https://forum.wixstudio.com/t/expandable-text-toggle-button-problem/38567>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [June 8, 2018, 9:06am UTC](https://forum.wixstudio.com/t/expandable-text-toggle-button-problem/38567 "2018-06-08T09:06:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastianskinnerup](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@sebastianskinnerup](https://forum.wixstudio.com/u/sebastianskinnerup)\
**Post date:** [June 8, 2018, 9:06am UTC](https://forum.wixstudio.com/t/expandable-text-toggle-button-problem/38567/1 "2018-06-08T09:06:52Z")

</div>

Hi,

I have just recently discovered that Wix had a feature released which alows me to have explandable textboxes (code), where I had to use FAQ before.

I followed the official wix-guide as to how:  
[https://support.wix.com/en/article/creating-an-expandable-text-box-with-a-show-more-link-using-wix-code](https://support.wix.com/en/article/creating-an-expandable-text-box-with-a-show-more-link-using-wix-code)

But unfortunatly im having some trouble getting the “show more/show less” button to work.

In the following URL’s you can have a look at my code and the placement of the button - right below the static text field:

> **[Code expandable text hosted at ImgBB](https://ibb.co/c8fCPsf)**
>
> Image Code expandable text hosted in ImgBB

> **[Fysioterapi hosted at ImgBB](https://ibb.co/KVYTJLb)**
>
> Image Fysioterapi hosted in ImgBB

WHAT HAPPENS?

- As I preview the site the text shortens to the desired amount of characters. The button follows the text and is still displayed right under. BUT, when I click the button nothing happens.

Im hoping one of you have an idea of what i am doing wrong. Help is much appreciated.

Thank you for reading and helping me out.

Kind regards,  
Sebastian Skinnerup

PS.  
I have searched the forum for answers and several people have had simular issues and solved them. But none of them posted the solution and stopped responding in their own thread when others requested their solution. I will (in case I ever solve it) post answers and how-to for future inquiries. 🙂

---

<div class="post-metadata">

**Author:** ![mqumseya](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/mqumseya/32/3999_2.png) [@mqumseya](https://forum.wixstudio.com/u/mqumseya)\
**Post date:** [June 11, 2018, 2:48pm UTC](https://forum.wixstudio.com/t/expandable-text-toggle-button-problem/38567/2 "2018-06-11T14:48:47Z")

</div>

Hello Sebastion,  
I have tried to do it with the code snippet, and changed a bit of the logic for the click event function. Have a look:

```javascript
// For full API documentation, including code examples, visit http://wix.to/94BuAAs
let fullText;
let shortText;

$w.onReady(function () {
 //TODO: write your page related code here...
 const shortTextLength = 3;
    fullText = $w('#text2').text;
    shortText = fullText.substr(0, shortTextLength) + '...';
    $w('#text2').text = shortText;
});

export function button1_click(event, $w) {
    console.log(shortText, fullText);
    if($w('#text2').text === shortText){
        $w('#text2').text = fullText;
    }else {
        $w('#text2').text = shortText;
    }
}

```

Hope this helps,  
Majd
