title: Identify $(this) in jQuery
body: <p>Whats the best way to find out what <code>$(this)</code> currently equals in jQuery?</p>
  
  <p>For example <code>alert(this);</code> isn't much help. </p>
  
  <p>The reason I ask is that a piece of code is not currently doing what it should do after I have moved the code into a function.</p>
  
  <p>The excerpt below is now in a function, and $(this) now seems to refer to the DOMWindow.</p>
  
  <pre><code>if($(this).hasClass('open'))
    {
      alert('I should be closed');
      $(this).removeClass('open').addClass('closed');
      $(this).parents('article').css('border', '1px solid red').animate({'width': '212px'}, 100, "linear", function() {
      run_masonry();
      });
    }
    else
    {
      alert('I should be open');
      $(this).removeClass('closed').addClass('open');
      $(this).parents('article').css('border', '1px solid blue').animate({'width': '646px'}, 100, "linear", function() {
      run_masonry();
    });
  }
  </code></pre>
  
  <p>How do I keep it as $(this) being the original clicked element?</p>