Need help pls (Hide/Show text with a button)

Hi everybody, I am a novice in code …

I make a hidden text that appears with clicking a button (button name : “+”).
This I have achieved ! :blush:

$w . onReady ( function () {
$w ( ‘#button’ ). onClick ( () => {
$w ( #hiddentext ). expand ();
});
});

Now I wish the button to change its name (to “-”) and when you click on it, the text disappears (initial status), and the button becomes “+” again.

it would be really great if someone could give me the rest of the code to reach my goal :blush:

Thanks a lot

How about this…

$w.onReady(function () {
  $w("#button").onClick(() => {
    if ($w("#hiddentext").collapsed) {
      $w(`#hiddentext`).expand();
      $w("#button").label = "-";
    } else {
      $w(`#hiddentext`).collapse();
      $w("#button").label = "+";
    }
  });
});

Note: to be consistent with variable naming conventions in JavaScript, you might want to rename the element ‘hiddentext’ to ‘hiddenText’, using camelcase capitalization.

Here’s the result – before click and after click:

@Jim Feuerstein,
A thousand thanks, it works perfectly with your help :blush:
I thank you sincerely and greetings from Switzerland.

NB. And with your note, I renamed elements using camelcase capitalization.

Thanks for the update!