I am developing a super simple site using jQuery and bootstrap libraries but I would like the menu items to jump to the section (already done with anchors). But when I navigate back to the top the menu dropdown is still open. How would I setup up a toggle so it closes on clicking a menu item?
This is my initial code:
$( document ).ready(function() {
$( ".cross" ).hide();
$( ".menu" ).hide();
$( ".hamburger" ).click(function() {
$( ".menu" ).slideToggle( "slow", function() {
$( ".hamburger" ).hide();
$( ".cross" ).show();
});
});
$( ".cross" ).click(function() {
$( ".menu" ).slideToggle( "slow", function() {
$( ".cross" ).hide();
$( ".hamburger" ).show();
});
});
});
<button class="hamburger">☰</button>
<button class="cross">˟</button>
<div class="menu">
<ul>
<a href="#"><li>Home</li></a>
<a href="#about"><li>Jeff Anderson</li></a>
<a href="#"><li>Hand Built Frames</li></a>
<a href="#"><li>Bike Repairs and Maintenance</li></a>
<a href="#"><li>Frames and Accessories</li></a>
<a href="#"><li>Contact</li></a>
</ul>
</div>
</div>
Any help greatly appreciated. Thanks.