I have the following:
// Menu
function openNav() {
document.querySelector("div.slider").style.width = "250px";
document.querySelector("div.slider").style.boxShadow = "-2px 0px 5px -1px rgba(0,0,0,0.75)";
}
function closeNav() {
document.querySelector("div.slider").style.width = "0";
document.querySelector("div.slider").style.boxShadow = "";
}
<nav>
<a href="index.html"><div class="logo"></div></a>
<div class="menu" onclick="openNav()">
<div class="slider">
<a href='#Home' onclick="closeNav()">Home</a>
<a href="#Services" onclick="closeNav()">Services</a>
<a href="#Portfolio" onclick="closeNav()">Portfolio</a>
<a href="#Team" onclick="closeNav()">Team</a>
<a href="#Contact" onclick="closeNav()">Contact</a>
</div>
</div>
</nav>
The slider will not close. I have also tried setting it up so that if I click outside of the div it will close but it isn't working. If I run 'closeNav()' in the console the nav closes fine but I can't seem to get the onclick to work.