Possible Duplicate:
How would you compare jQuery objects?
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 div
. My code looks like this:
var curPin;
$('.pin').click(function(){
var $pin = $(this);
if (curPin == $pin){
console.log('true');
} else {
curPin = $pin;
console.log('false');
}
}
Why is this not coming up as equal? Is there a better way to do this?