Reputation: 29
on clicking nav-icon class "show-menu" has added to the body,but on clicking class nav-close the class show-menu has not removed from the body
$(document).ready(function(){ $('.nav-icon').click(function(e) { e.stopPropagation(); if(!$('body').hasClass("show-menu") ){ $('body').addClass("show-menu"); }; }); $('.nav-close').click(function(){ if( $('body').hasClass("show-menu") ){ $('body').removeClass("show-menu"); }; }); });
Upvotes: 1
Views: 83
Reputation: 669
Try putting your functions outside $(document).ready(function(){});
only put functions inside $(document).ready
when you want you execute the functions when the page or DOM elements are loaded i don't think you need to place your code inside it.
Upvotes: 0