How to access properties of function within function
<p>How do I access <code>isExpanded</code>, <code>collapsedHeight</code> and <code>expandedHeight</code> inside the jQuery click handler for <code>element</code>.<br/><strong>The way it's written now won't work because <code>this</code> means something else inside the click handler than it does outside of it.</strong></p>

<pre><code>function CoolSelect(element)
{
    this.element=element;
    this.isExpanded=false;
    this.collapsedHeight=$(element).height();
    this.expandedHeight=this.collapsedHeight+$('ul',element).height();

    $(this.element).click(function()
    {
        var newHeight;
        if(this.isExpanded){newHeight=this.collapsedHeight;}
        else{newHeight=this.expandedHeight;}
        $(this.element).animate({height:newHeight},100,'liniar');
    });
}
</code></pre>

<p>Thank you.</p>
