title: JavaScript Onclick Dropdown Menu not working
body: <p>I am trying to make an onclick dropdown menu for a website. I want my .sublink elements to slide down when I click on the .dropdown element and then for the .sublink to slide back up when I click on anywhere else on the page.</p>
  
  <p><strong>The menu drops down, but it does not slide back up when I click somewhere else on the website.</strong> </p>
  
  <p>Following is the code that I currently have for the menu.   Can someone please help me on this? Thank you!</p>
  
  <pre><code>$(function() {
  $('.dropdown').click(function() {
      $('.sublinks').stop(false, true).hide();
  
      var submenu = $(this).parent().next();
  
      submenu.css({
          position: 'absolute',
          top: $(this).offset().top + $(this).height() + 'px',
          left: $(this).offset().left + 'px',
          zIndex: 1000
      });
  
      submenu.stop().slideDown(300);
  
  
  
     //click anywhere outside the menu
     $(document).click(function() {
          var $el = $(this);
          $el.not('.dropdown') &amp;&amp; $el.slideUp(300);
      });
  });
  });
  </code></pre>