Whats the best way to find out what $(this) currently equals in jQuery?

For example alert(this); isn't much help.

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.

The excerpt below is now in a function, and $(this) now seems to refer to the DOMWindow.

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();
  });
}

How do I keep it as $(this) being the original clicked element?

Edit
Report