jQuery - DOM elements not being identified as equal
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2436966/how-would-you-compare-jquery-objects">How would you compare jQuery objects?</a>  </p>
</blockquote>



<p>I'm using jQuery to store the actively clicked item in a list of items. I want to detect if the newly clicked item is the same as the one previously clicked, to toggle the visibility of a supporting <code>div</code>. My code looks like this:</p>

<pre><code>var curPin;

$('.pin').click(function(){
  var $pin = $(this);
  if (curPin == $pin){
    console.log('true');
  } else {
    curPin = $pin;
    console.log('false');
  }
}
</code></pre>

<p>Why is this not coming up as equal? Is there a better way to do this?</p>
