# Getting Elements to show on Button click

**URL:** <https://forum.wixstudio.com/t/getting-elements-to-show-on-button-click/38679>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [July 25, 2022, 10:58am UTC](https://forum.wixstudio.com/t/getting-elements-to-show-on-button-click/38679 "2022-07-25T10:58:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dan111\_111](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@dan111\_111](https://forum.wixstudio.com/u/dan111_111)\
**Post date:** [July 25, 2022, 10:58am UTC](https://forum.wixstudio.com/t/getting-elements-to-show-on-button-click/38679/1 "2022-07-25T10:58:20Z")

</div>

Hi everyone!

So I have ben setting up a page where it shows all the staff that works at both sites of the company.

The Intention is when someone clicks on a button It shows all the photos, Container Box and some text on them, But I can’t seem to get the code to work at all. When I thought I had it all working in preview mode clicking the button just won’t bring them.

Each of the things that are supposed to be appearing are set to hidden and all their element names in the code correspond to what they have been labelled as.

The Button also make some other things dissapire. Something I can’t test if it works as I haven’t set up the code for it to appear yet.

Below is the code im using.

export function LauncestonButton\_click ( event ) {  
// This function was added from the Properties & Events panel. To learn more, visit [About the Properties & Events Panel](http://wix.to/UcBnC-4)  
// Add your code for this event here:

$w ( ‘#AnnaBox’ ). show  
$w ( ‘#AnnaLabel’ ). show  
$w ( ‘#AnnaPhoto’ ). show  
$w ( ‘#DonnaBox’ ). show  
$w ( ‘#DonnaLabel’ ). show  
$w ( ‘#DonnaPhoto’ ). show  
$w ( ‘#NitaBox’ ). show  
$w ( ‘#NitaLabel’ ). show  
$w ( ‘#NitaPhoto’ ). show  
$w ( ‘#DaisyBox’ ). show  
$w ( ‘#DaisyLabel’ ). show  
$w ( ‘#DaisyPhoto’ ). show  
$w ( ‘#MiaBox’ ). show  
$w ( ‘#MiaLabel’ ). show  
$w ( ‘#MiaPhoto’ ). show  
$w ( ‘#KateBox’ ). show  
$w ( ‘#KateLabel’ ). show  
$w ( ‘#KatePhoto’ ). show  
$w ( ‘#DanielBox’ ). show  
$w ( ‘#DanielLabel’ ). show  
$w ( ‘#DanielPhoto’ ). show  
$w ( ‘#GemmaBox’ ). show  
$w ( ‘#GemmaLabel’ ). show  
$w ( ‘#GemmaPhoto’ ). show  
$w ( ‘#KarenBox’ ). show  
$w ( ‘#KarenLabel’ ). show  
$w ( ‘#KarenPhoto’ ). show  
$w ( ‘#PeggyPhoto’ ). show  
$w ( ‘#PeggyLabel’ ). show  
$w ( ‘#PeggyBox’ ). show  
$w ( ‘#GeorgiaBox’ ). show  
$w ( ‘#GeorgiaLabel’ ). show  
$w ( ‘#GeorgiaPhoto’ ). show  
$w ( ‘#KaitlinBox’ ). show  
$w ( ‘#KaitlinLabel’ ). show  
$w ( ‘#SarahBox’ ). show  
$w ( ‘#SarahLabel’ ). show  
$w ( ‘#SarahPhoto’ ). show

$w ( ‘#EllieBox’ ). hide  
$w ( ‘#StephBox’ ). hide  
$w ( ‘#RosieBox’ ). hide  
$w ( ‘#SofiaBox’ ). hide  
$w ( ‘#ClaireBox’ ). hide  
$w ( ‘#DianeBox’ ). hide  
$w ( ‘#CharlotteBox’ ). hide  
$w ( ‘#EmilyBox’ ). hide  
$w ( ‘#KirstyBox’ ). hide  
$w ( ‘#VickyBox’ ). hide  
$w ( ‘#HelenBox’ ). hide  
$w ( ‘#HarrietBox’ ). hide  
$w ( ‘#TaniaBox’ ). hide  
$w ( ‘#EvieBox’ ). hide

$w ( ‘#EllieLabel’ ). hide  
$w ( ‘#StephLabel’ ). hide  
$w ( ‘#RosieLabel’ ). hide  
$w ( ‘#SofiaLabel’ ). hide  
$w ( ‘#ClaireLabel’ ). hide  
$w ( ‘#DianeLabel’ ). hide  
$w ( ‘#CharlotteLabel’ ). hide  
$w ( ‘#EmilyLabel’ ). hide  
$w ( ‘#KirstyLabel’ ). hide  
$w ( ‘#VickyLabel’ ). hide  
$w ( ‘#HelenLabel’ ). hide  
$w ( ‘#HarrietLabel’ ). hide  
$w ( ‘#TaniaLabel’ ). hide  
$w ( ‘#EvieLabel’ ). hide

$w ( ‘#ElliePhoto’ ). hide  
$w ( ‘#StephPhoto’ ). hide  
$w ( ‘#RosiePhoto’ ). hide  
$w ( ‘#SofiaPhoto’ ). hide  
$w ( ‘#ClairePhoto’ ). hide  
$w ( ‘#DianePhoto’ ). hide  
$w ( ‘#CharlottePhoto’ ). hide  
$w ( ‘#EmilyPhoto’ ). hide  
$w ( ‘#KirstyPhoto’ ). hide  
$w ( ‘#VickyPhoto’ ). hide  
$w ( ‘#HelenPhoto’ ). hide

$w ( ‘#EllieText’ ). hide  
$w ( ‘#StephText’ ). hide  
$w ( ‘#RosieText’ ). hide  
$w ( ‘#SofiaText’ ). hide  
$w ( ‘#ClaireText’ ). hide  
$w ( ‘#DianeText’ ). hide  
$w ( ‘#CharlotteText’ ). hide  
$w ( ‘#EmilyText’ ). hide  
$w ( ‘#KirstyText’ ). hide  
$w ( ‘#VickyText’ ). hide  
$w ( ‘#Helentext’ ). hide

$w ( ‘#EllieTextBox’ ). hide  
$w ( ‘#StephTextBox’ ). hide  
$w ( ‘#RosieTextBox’ ). hide  
$w ( ‘#SofiaTextBox’ ). hide  
$w ( ‘#ClaireTextBox’ ). hide  
$w ( ‘#DianeTextBox’ ). hide  
$w ( ‘#CharlotteTextBox’ ). hide  
$w ( ‘#EmilyTextBox’ ). hide  
$w ( ‘#KirstyTextBox’ ). hide  
$w ( ‘#VickyTextBox’ ). hide  
$w ( ‘#HelenTextBox’ ). hide  
$w ( ‘#HarrietTextBox’ ). hide  
$w ( ‘#TaniaTextBox’ ). hide  
$w ( ‘#EvieTextBox’ ). hide

}

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [July 27, 2022, 10:34pm UTC](https://forum.wixstudio.com/t/getting-elements-to-show-on-button-click/38679/2 "2022-07-27T22:34:29Z")

</div>

See in red:

```javascript
$w('#AnnaBox').show();
$w('#EvieTextBox').hide();

```

---

<div class="post-metadata">

**Author:** ![Rob](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/rob/32/84134_2.png) [@Rob](https://forum.wixstudio.com/u/Rob)\
**Post date:** [June 26, 2025, 7:41pm UTC](https://forum.wixstudio.com/t/getting-elements-to-show-on-button-click/38679/3 "2025-06-26T19:41:05Z")

</div>

To add context to JD’s post, to properly show and/or hide an element, it should have the parenthesis like .show()and .hide(). Hence his updated code.

Additionally, I’ve been testing out arrays for some of my code so I wanted to try it here and I think this should work.

```javascript
export function LauncestonButton_click(event) {
    // Elements to show
    const showElements = [
        '#AnnaBox', '#AnnaLabel', '#AnnaPhoto',
        '#DonnaBox', '#DonnaLabel', '#DonnaPhoto',
        '#NitaBox', '#NitaLabel', '#NitaPhoto',
        '#DaisyBox', '#DaisyLabel', '#DaisyPhoto',
        '#MiaBox', '#MiaLabel', '#MiaPhoto',
        '#KateBox', '#KateLabel', '#KatePhoto',
        '#DanielBox', '#DanielLabel', '#DanielPhoto',
        '#GemmaBox', '#GemmaLabel', '#GemmaPhoto',
        '#KarenBox', '#KarenLabel', '#KarenPhoto',
        '#PeggyPhoto', '#PeggyLabel', '#PeggyBox',
        '#GeorgiaBox', '#GeorgiaLabel', '#GeorgiaPhoto',
        '#KaitlinBox', '#KaitlinLabel',
        '#SarahBox', '#SarahLabel', '#SarahPhoto'
    ];

    // Elements to hide
    const hideElements = [
        '#EllieBox', '#StephBox', '#RosieBox', '#SofiaBox', '#ClaireBox', '#DianeBox',
        '#CharlotteBox', '#EmilyBox', '#KirstyBox', '#VickyBox', '#HelenBox',
        '#HarrietBox', '#TaniaBox', '#EvieBox',
        '#EllieLabel', '#StephLabel', '#RosieLabel', '#SofiaLabel', '#ClaireLabel',
        '#DianeLabel', '#CharlotteLabel', '#EmilyLabel', '#KirstyLabel', '#VickyLabel',
        '#HelenLabel', '#HarrietLabel', '#TaniaLabel', '#EvieLabel',
        '#ElliePhoto', '#StephPhoto', '#RosiePhoto', '#SofiaPhoto', '#ClairePhoto',
        '#DianePhoto', '#CharlottePhoto', '#EmilyPhoto', '#KirstyPhoto', '#VickyPhoto',
        '#HelenPhoto',
        '#EllieText', '#StephText', '#RosieText', '#SofiaText', '#ClaireText',
        '#DianeText', '#CharlotteText', '#EmilyText', '#KirstyText', '#VickyText',
        '#HelenText',
        '#EllieTextBox', '#StephTextBox', '#RosieTextBox', '#SofiaTextBox', '#ClaireTextBox',
        '#DianeTextBox', '#CharlotteTextBox', '#EmilyTextBox', '#KirstyTextBox', '#VickyTextBox',
        '#HelenTextBox', '#HarrietTextBox', '#TaniaTextBox', '#EvieTextBox'
    ];

    showElements.forEach(id => $w(id).show());
    hideElements.forEach(id => $w(id).hide());
}

```
