title: Jquery - Add class on click of button / Remove class on click of body
body: <p>I have a div that I want to show when a button is clicked, and then if anywhere else on the page (including the original button) except for that hidden div is clicked then I want the div to hide again.</p>
  
  <p>I think I'm pretty close, just can't get it right. This is what I have so far (as a basic example:</p>
  
  <pre><code>$(".clickme").click(function () {
      $(".toggletag").addClass('open');
  });
  if ( $('.toggletag').hasClass('open') ) {
      $("html").click(function () {
          $(".toggletag").removeClass('open');
      });
  }
  </code></pre>
  
  <p>Here is a JSfiddle using this code: <a href="http://jsfiddle.net/vgf6g/1/">http://jsfiddle.net/vgf6g/1/</a></p>
  
  <p>I tried without the if statement at first but that of course caused the html click to override the button click causing the div to never show.</p>
  
  <p>Thanks!</p>