Javascript menu close
<p>I have a menu in HTML. When you click "menu", a list opens, click "menu" again, the list closes.</p>

<p>I need the menu to close if the user clicks anywhere on the screen</p>

<pre><code>&lt;script type="text/javascript"&gt;
$(function() {
  var menuVisible = false;

    $('#menuBtn').click(function() { 
    if (menuVisible) {
      $('#menu').css({
        'display': 'none'
      });
      menuVisible = false;
      return;
    }
    $('#menu').css({
      'display': 'block'
    });
    menuVisible = true;
  });
  $('#menu').click(function() {
    $(this).css({
      'display': 'none'
    });
    menuVisible = false;
  });
});
</code></pre>

<p></p>