jQuery - access variable out of a jQuery function
<p>guys. I have something like this:</p>

<pre><code>myThing = {
    str:"my string",
    setClick: function(){
        $("button").click(function(){
            alert(this.str);
        });
    }
}

myThing.setClick();
</code></pre>

<p>The problem is when I click the button the function doesn't know what str is. <code>alert(str)</code> gives me an error (<code>str is not defined</code>) and no alerts. <code>alert(this.str)</code> gives me the alert but containing <code>undefined</code>.</p>

<p>I can see that <code>this</code> reffers to the button and the button doesn't have any attribute called <code>str</code>. So how can I access the str that is out of jQuery's function?</p>
