title: Close box click outside of it
body: <p>I got a code from web. I click on text > opens a box.</p>
  
  <p>I want to close the box when I click outside of box.</p>
  
  <p>This is my javascript code:</p>
  
  <pre><code>function setVisibility(id, visibility) {
  document.getElementById(id).style.display = visibility;
  }
  </code></pre>
  
  <p>This is my HTML code:</p>
  
  <pre><code>&lt;div value='Show Layer' onclick="setVisibility('sub2', 'inline');"&gt;
    &lt;span&gt;SHOW BOX&lt;/span&gt;
  &lt;/div&gt;
  
  &lt;div id="sub2"&gt;
    &lt;p&gt;This is a test for box.&lt;/p&gt;
    &lt;button value='Hide Layer' onclick="setVisibility('sub2', 'none');" ;&gt;Click to close box&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This is my CSS code:</p>
  
  <pre><code> #sub2 { width: 500px; color: black; display: none; background:#eeeeee; display: none; /* Hidden by default */ position: fixed; /* Stay in place */ z-index: 1; overflow: auto; / }
   #sub2 h5 { font-family: 'Varela Round', sans-serif; font-size:20px; }
  </code></pre>