title: jquery close on click outside
body: <p>i have made a side navigation menu which slides from left to right on the click of a button.</p>
  
  <pre><code>$(document).ready(function(){
    $("#nav-toggle").click(function(){
      $("#page").toggleClass("margin");
    });
  });
  </code></pre>
  
  <p>when the '#nav-toggle' button is clicked the '#page' margin increases from 0px to 600px.</p>
  
  <pre><code>    .margin {
  margin-left:600px;width:380px;overflow-x:hidden
  }
  
  
  &lt;div id="side-menu"&gt;
  
  &lt;nav&gt;
      &lt;a class="nav-links" href="#home"&gt;home&lt;/a&gt;
      &lt;a class="nav-links" href="#about"&gt;about&lt;/a&gt;
      &lt;a class="nav-links" href="#contact"&gt;contact&lt;/a&gt;
  &lt;/nav&gt;&lt;!-- end of nav  --&gt;
  </code></pre>
  
  <p></p>
  
  <p>how would i close the menu by clicking outside of it.</p>