Collapsing effect

Hey there!
I’m trying to create a collapsing effect on a page, though it’s not working properly. The scenario is as follows:
I’ve 3 columns on the same page, each column following the same logic.

  1. Main title
  2. Secondary title
  3. Arrow (added feature)
  4. Text
  5. Button (added feature - to be linked to a different page by click)

I pretend to hid the text and the button, so they’re only visible when someone clicks on the arrow. By clicking on the arrow the text should show downward as well the button.
Unfortunately, I cannot make it work the way I’d like. I’ve used the collapse and expand function (see example below), the text and button collapse, though 2 issues arise:

  • Button is inactive (it’s greyed out)
  • Column size does not match the text length, meaning that there is a big empty space before one clicks on the arrow that just sits there the whole time. The idea is for the column to become bigger the minute one clicks on the arrow and the text shows, and then retracts again with a second click making the text (and the button) disappear.

export function Arrow2_click(event) {
//Add your code for this event here:
if ( $w(“#Text2”).collapsed ) {
$w(“#Text2”).expand()
$w(“#Button2”).expand();
}
else {
$w(“#Text2”).collapse()
$w(“#Button2”).collapse();
}
}

Could someone help me out?
Would be more than glad to provide additional clarifications.

Thank you so much!!
Diana

There are already examples that you can look at yourself.

From Wix.
https://www.wix.com/corvid/example/collapse-elements

From Nayeli (Code Queen)
https://www.totallycodable.com/wix/corvid/create-custom-faq-with-double-collapse-effect

Appreciate the reply!
Already looked at both of them…code queen seems a pretty good example and I’m using her code/functions. However, it’s still not working for me. I’m bumping the elements to the previous one has mentioned by her and I’m using a box where I input the text and button. Plus, she does not have a linked box (like the button I’m using) and I’m not sure if it has any influence at all.
The first example seems a bit more complex, especially compared with what I’d like to achieve.

Unfortunately I’m not an expert in code language :slight_smile:
Is there anyone else who could give me some tips considering the example above? I’ve been completely stuck for the past weeks…

Thank you all for your support!