Reputation: 15
I want my responsive navigation to toggle, the code below just expand the Menu button to the different pages. I want to toggle it, so now it just expand but not fold it in.
HTML:
<nav> <a href="#footer_nav" >☰ MENU</a> <ul> <li><a href="#">Home</a></li> <li><a href="#">Opleiding</a></li> <li><a href="#">Onderwijsprogramma</a></li> <li><a href="#">Organisatie</a></li> <li><a href="#">Stages en projecten</a></li> </ul> </nav>
CSS:
.in-visible { display: none; list-style: none; margin-left: 0; padding-left: 0; margin-bottom: 0; }
.visible { display: block; }
Javascript:
var responsivenav = document.querySelector('header > nav > ul');
responsivenav.classList.add('in-visible');
document.querySelector('header > nav > a').onclick = function(){ responsivenav.classList.add('visible'); }
Someone can help me please?
Upvotes: 0
Views: 634