Reputation: 1
I'm currently working on a full screen navigation menu that opens when I click the hamburger icon. Right now I am able to toggle the navigation by adding a class called "open" that triggers when I click on the menu. But I am stuck when it comes to closing it. Could you review my code and let me know what I'm missing?
$(document).ready(function() {
$('#menu').on('click', function() {
$('.overlay').addClass('open');
$('#menu').removeClass('open-menu');
$('#menu').addClass('close-menu');
});
$('.#menu').on('click', function() {
$('.overlay').removeClass('open');
$('#menu').addClass('open-menu');
$('#menu').removeClass('close-menu');
});
});
Upvotes: 0
Views: 100
Reputation: 528
use toogle function for this like
$( "#target" ).toggle(function() {
alert( "First handler for .toggle() called." );
}, function() {
alert( "Second handler for .toggle() called." );
});
Upvotes: 1