I was trying to make side navigation bar open with a checkbox but when I check the box the side bar doesn't appear

Viewed 174

Any ideas where I went wrong? I have tried setting width to 0 inside CSS and using JavaScript to add width it still didn't work.

 
 function showsidenav(){
      document.getElementsById("barres").style.display = "block"; 
   }                                         
    
.opened-side-nav {
    background-color: ghostwhite;
    width: 30%;
    height: 100%;
    position: absolute;
    border-right: black 2px solid;
    z-index: 1;
    overflow: hidden;
    display: none;
 }
<!--Nav Bar-->
<div class="opened-side-nav" id="barres">Content</div>
    <div class="logo">
        <input  id="5055" class="showsidenavbar" type="checkbox" onclick="showsidenav()">
        <label for="5055">=</label> 
    </div>
</div>

1 Answers

Use getElementById and not getElementsById. For id, there's no 's' in Element. The 's' in the spelling is causing it, that is if your code is working fine.

Related