Jquery slidedown if statement not comparing $(this)
<p>I have a list of buttons to be clicked on.  I want a div to slide down if the link that is clicked is new, but if it is the same one that was last clicked, I just want the div to slide up.</p>

<p>So my code is:</p>

<pre><code>var $lastflyout = '';
$('.links-text a').each(function(){
    $(this).click(function(){
        if($(this) == $lastflyout) {
            alert('last equals');
            $('#flyout').slideUp(500);
        }
        else {
            $('#flyout').slideUp(500);
            $('#flyout').slideDown(500);
        }
        $lastflyout = $(this);


    });

});
</code></pre>

<p>And for some reason it is never alerting 'last equals', thus never getting into the first if statement.  I tried alerting $lastflyout and it says that it is an object after the first click but I don't know why that first if statement isn't working.</p>

<p>Thanks for the help.</p>
