title: Jquery check if clicked, else do this
body: <p>Why does it ignore the click and goes to the else statement? Any help is appreciated!</p>
  
  <pre><code>&lt;div id="boxauto"&gt; &lt;a id="boxclose"&gt;X&lt;/a&gt; error &lt;/div&gt;
  
  &lt;script&gt;
      window.setTimeout(function(){
          $('#boxauto').delay(50).animate({'top':'0'},200); 
  
          var hasBeenClicked = false;
          jQuery('#boxclose').click(function(){
             hasBeenClicked = true;
          });
          if(hasBeenClicked) {
              $('#boxauto').animate({'top':'-50em'},500);
          } else {
              $('#boxauto').delay(5000).animate({'top':'-50em'},500);
          }
      });
  &lt;/script&gt;
  </code></pre>