title: jQuery: Close DIV by clicking anywhere apart from the DIV itself?
body: <p>I have a div that slides down when a button is clicked, and I would like to slide up the div when a user:</p>
  
  <ol>
  <li>Clicks anwhere except within the DIV itself</li>
  <li>Click a close button within the div.</li>
  </ol>
  
  <p>Currently I've got it to a stage where, you click an element with the class <code>.panel-tab</code> - it slides down the panel with ID <code>#panel</code>... click anywhere else it slides up....</p>
  
  <p>Here is my code so far to get the DIV to open and close:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function(){
  
  $('.panel-tab').click(function(e) {
    $("#panel").stop(true, true).slideToggle("slow");
    e.stopPropagation();
  });
  
  $("body").click(function () {
    $("#panel:visible").stop(true, true).slideUp("slow");
  });});
  &lt;/script&gt;
  </code></pre>