title: Using JQuery to open close menu
body: <p>ok so I have this script that controls an open/close of menu .... </p>
  
  <p>of the three major functions (seen below) the first two work well in that the button-toggle changes its class (to an X) "active" which makes it an X.  </p>
  
  <p>However the fourth (commented out )function doesn't work... This was designed so that when you click on the body or anywhere other than the menu when it is open , it will close.  please can someone help me to rewrite the last function so that it works.   </p>
  
  <pre><code>$(document).ready(function () {
      var $navToggle = $('.nav-toggle');
      $(".navbtn").click(function () {
          if($navToggle.hasClass('active')){
              $('#menu').multilevelpushmenu('collapse');
              $navToggle.removeClass('active');
              $(this).addClass('active');
          }
          else{
              $('#menu').multilevelpushmenu('expand');
              $navToggle.addClass('active');
              $(this).removeClass('active');
          }
      });
  $(".navbtn").hover(function () {
      $('.nav-toggle').addClass('hover');
  },function(){
      $('.nav-toggle').removeClass('hover');
  });
  
  
  /*$('body').on('click', function(e){
   if( !$(this).closest('#menu, .navbtn, .nav-toggle').length) {
      $('#menu').multilevelpushmenu('collapse');
      $navToggle.removeClass('active');
          e.stopPropagation();        
      }; 
  });*/
  });
  </code></pre>
  
  <p>I have provided a JSFiddle below (The menu is set to full colapse on startup not open as in the demo fyi)</p>
  
  <p><a href="http://jsfiddle.net/greggy_coding/ppX53/66/" rel="nofollow">http://jsfiddle.net/greggy_coding/ppX53/66/</a></p>