So I am trying to use the same button to toggle on and off a side menu. However when I click the button nothing happens to the side menu. The code looks like it should work but I cannot figure out why it's not.
The menu should change height from 0 to 220px, the links from 0 to 1 opacity and from hidden to visible and the reverse when clocked again. But the only thing I can get to work is the hamburger animation on click. Any help?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Document</title>
</head>
<nav>
<section id="navbar">
<!-- Navigation Topper -->
<div class="container topper-flex">
<div class="topper-content">
<i class="fas fa-phone"></i>
<p class="topper-content">(354) 994-6746</p>
<i class="fas fa-phone"></i>
<p class="topper-content">bobbylarrys@icloud.com</p>
<i class="fas fa-phone"></i>
<p class="topper-content">117 Southeast 4th Ave Deerfield Beach, FL 33441</p>
</div>
</div>
<!-- Mobile Navigation Header -->
<div class="mobile-nav container">
<img id="mobile-logo-1" src="images/maple-logo.png" alt="test" height="50" width="160">
<!-- Hamburger Menu -->
<div class="open-slide container">
<div id="wrapper" onclick="toggleNav()">
<div class="main-item menu ">
<span class="line line01"></span>
<span class="line line02"></span>
<span class="line line03"></span>
</div>
</div>
</div>
</div>
<!-- Middle navigation -->
<div id="brand">
<div class="brand-bar container">
<img src="images/maple-logo.png" alt="test" height="50" width="160">
<div class="branding-bar container">
<div class="quote">
<!-- Icon -->
<div class="quote-block">
<p>NEED AN ESTIMATE</p>
<p>GET A FREE QUOTE</p>
</div>
</div>
<div class="call">
<!-- Icon -->
<div class="call-block">
<p>CALL US NOW</p>
<p>(354) 994-6746</p>
</div>
</div>
</div>
</div>
</div>
<!-- Desktop Navbar -->
<div class="navbar-menu">
<div class="container">
<ul class="navbar-links">
<li><a class="active" href="index.html">HOME</a></li>
<li><a href="about.html">ABOUT</a></li>
<li><a href="dent.html">DENT REPAIR</a></li>
<li><a href="gallery.html">GALLERY</a></li>
<li><a href="contact.html">CONTACT US</a></li>
</ul>
</div>
</div>
</section>
</nav>
<!-- Side menu -->
<div id="side-menu" class="side-nav">
<ul id="on-top">
<li class="nav-item"><a class="side-active" href="index.html">HOME</a></li>
<li class="nav-item"><a href="services.html">ABOUT</a></li>
<li class="nav-item"><a href="jobs.html">DENT REPAIR</a></li>
<li class="nav-item"><a href="about.html">GALLERY</a></li>
<li class="nav-item"><a href="contact.html">CONTACT US</a></li>
</ul>
</div>
<body>
<script type="text/javascript" src="nav.js"></script>
<script type="text/javascript" src="test.js"></script>
</body>
</html>
body {
margin: 0;
padding: 0;
}
* {
font-family: 'Lato', sans-serif;
}
.container {
padding: 2em 0;
}
/* hidden desktop elements */
.topper-flex,
#brand,
.navbar-menu {
display: none;
}
/*-- -------------------------- -->
<--- NAVIGATION -->
<--- -------------------------- -*/
.navbar {
height: auto;
display: flex;
flex-direction: row;
align-items: center;
}
/* logo and hamburger container */
.mobile-nav {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
padding: 0;
height: 100px;
background: #000;
position: relative;
}
/* Hamburger Menu */
.open-slide {
display: inline-block;
width: auto;
padding: 0;
position: absolute;
right: 2em;
top: 36px;
}
#wrapper {
background: transparent;
display:inline-block;
margin:0px;
position: absolute;
cursor:pointer;
right: 0;
}
.main-item {
width:30px;
height:30px;
position:relative;
}
.line {
position: absolute;
height: 2px;
width:100%;
background:white;
border-radius:1.5px;
transition: all cubic-bezier(0.25, 0.1, 0.28, 1.54) 0.32s;
}
.line01 {
top:19%;
}
.line02 {
top:49%;
}
.line03 {
top:79%;
}
.menu.close .line01 {
transform:rotate(45deg);
top:49%;
}
.menu.close .line02, .menu.close .line03 {
transform:rotate(-45deg);
top:49%;
}
/* Hidden Menu */
#side-menu {
background: #231F20;
}
.side-nav {
visibility: hidden;
height: 0;
transition: 0.3s
}
.side-active {
color: #C47625;
}
ul {
text-align: center;
padding: 30px 0;
margin: 0;
}
ul a {
text-decoration: none;
color: #999;
line-height: 2em;
font-weight: 700;
transition: 0.3s ease;
}
ul li {
list-style: none;
}
.menu-center {
position: absolute;
top: 9px;
}
.menu-bottom {
position: absolute;
bottom: 0;
}
/* jQuery for the navigation animation */
$("#wrapper").click( function() {
$(".menu").toggleClass("close");
});
/* Code for the toggling of the navbar */
let toggleNavStatus = false;
let toggleNav = function () {
let getSidebar = document.querySelector(".side-nav");
let getSidebarUL = document.querySelector(".side-nav ul");
let getSidebarLinks = document.querySelectorAll(".side-nav a");
if (toggleNavStatus === false) {
getSidebarUL.style.visibility = "visible";
getSidebarLinks.style.opacity = "1";
getSidebar.style.height = "220px";
toggleNavStatus = true;
}
else if (toggleNavStatus === true) {
getSidebarUL.style.visibility = "hidden";
getSidebarLinks.style.opacity = "0";
getSidebar.style.height = "0";
toggleNavStatus = false;
}
}