I am trying to fix a small issue where my dropdown menu is not collapsed by default when switching to another page, it acts as if it was opened and closes when I press the toggle button. Is there any simple way to fix this? I haven't found other questions to help my situation out.
HTML
<label id="menulabel"></label>
<nav id="navbar">
<ul id="Mainnav">
<li class="hem">
<a href="index.html">
<p>Hem<p>
</a>
</li>
<li id="portfolio">
<a href="#">
Portfolio ˅
</a>
<ul id="Subnav">
<li>
<a href="illustrator.html">
Illustrator
</a>
</li>
<li>
<a href="photoshop.html">
Photoshop
</a>
</li>
<li>
<a href="illustrator.html">
InDesign
</a>
</li>
</ul>
</li>
CSS
#menulabel {
float:right;
display: block;
width: 44px;
height: 44px;
cursor: pointer;
background: url(../img/icon/Menu.png) no-repeat center center;
}
ul#Mainnav {
margin-left:0;
background:#000000;
clear:left;
}
ul#Mainnav > li {
float:none;
width:auto;
text-align: center;
display:block;
margin: 0;
padding: 0;
}
a {
color:white;
font-weight:bold;
}
ul#Mainnav > li:hover {
background: rgba(65, 177, 255, 1);
}
#Subnav {
display:none;
}
#Subnav.active {
display:block;
}
JQUERY
$("#menulabel").click(function() {
$("#navbar").toggleClass("active").stop(true, true).slideToggle(300);
});