# Why is my code not working when I'm trying to show and hide the navbar

**URL:** <https://discourse.processing.org/t/why-is-my-code-not-working-when-im-trying-to-show-and-hide-the-navbar/38195>\
**Category:** Beginners\
**Created:** [August 2, 2022, 2:18pm UTC](https://discourse.processing.org/t/why-is-my-code-not-working-when-im-trying-to-show-and-hide-the-navbar/38195 "2022-08-02T14:18:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dija\_321](https://avatars.discourse-cdn.com/v4/letter/d/ccd318/32.png) [@dija\_321](https://discourse.processing.org/u/dija_321)\
**Post date:** [August 2, 2022, 2:18pm UTC](https://discourse.processing.org/t/why-is-my-code-not-working-when-im-trying-to-show-and-hide-the-navbar/38195/1 "2022-08-02T14:18:45Z")

</div>

HTML:  
\<!doctype html\>

 navbar 

- Home 

CSS:

.container{  
background-color: black;  
height:100vh;  
width:0vw;

}

JS:  
let btn=0; //hidden

button=()=\>{  
if(btn!=0){  
document.getElementsByClassName(‘container’).style.width(‘100%’)

```
document.getElementsByClassName('list').style.display('block')

   btn=1;
}

```

else{  
document.getElementsByClassName(‘container’).style.width(‘0%’)  
document.getElementsByClassName(‘list’).style.display(‘none’)  
btn=0

}  
}
