title: hasClass not working when added dynamically
body: <p>Trying to learn javascript and jquery, so be easy on me please.</p>
  
  <p>Problem is, when i click on MENU, menu shows up but when i click BODY, it doesnt disappear. Why?</p>
  
  <pre><code>&lt;div class="menu"&gt;MENU&lt;/div&gt;
  &lt;nav class="hide-nav"&gt;
      &lt;ul&gt;
          &lt;li&gt;Level 1&lt;/li&gt;
          &lt;li&gt;Level 1&lt;/li&gt;
          &lt;li&gt;Level 1&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/nav&gt;
  
  $('.menu').on('click', function(){
    $('nav').removeClass('hide-nav').addClass('show-nav');
  });
  
  if ( $('nav').hasClass('show-nav') ) {
    $('body').on('click', function(){
      $(nav).removeClass('show-nav');
    });
  }
  </code></pre>