How can I pass arguments to anonymous functions in JavaScript?
<p>I'm trying to figure out how to pass arguments to an anonymous function in JavaScript.</p>

<p>Check out this sample code and I think you will see what I mean:</p>

<pre><code>&lt;input type="button" value="Click me" id="myButton" /&gt;

&lt;script type="text/javascript"&gt;
    var myButton = document.getElementById("myButton");
    var myMessage = "it's working";
    myButton.onclick = function(myMessage) { alert(myMessage); };
&lt;/script&gt;
</code></pre>

<p>When clicking the button the message "it's working" should appear... but the <code>myMessage</code>-variable inside the anonymous function is null.</p>

<p>This problem becomes much more evident when using jQuery since it uses a lot of anonymous functions.</p>

<p>How can I do this?</p>
