I have a nav in a box with this html:
<nav class="menu" id="theMenu"> <div class="menu-wrap"> <h1 class="logo"><a href="index.html#home">LOGO</a></h1> <i class="icon-remove menu-close"></i> <a href="#headerwrap">HOME</a> <a href="#information">INFO</a> <a href="#portfolio">Portfolio</a> </div> <!-- Menu button --> <div id="menuToggle"><i class="icon-reorder"></i></div> </nav> And this jQuery:
;(function(){ // Menu settings $('#menuToggle, .menu-close').on('click', function(){ $('#menuToggle').toggleClass('active'); $('body').toggleClass('body-push-toleft'); $('#theMenu').toggleClass('menu-open'); }); })(jQuery) Can you please help me and write me what I have to add in the js to close my menu when I click in the menu button but ALSO when I clicked outside ?