Dynamically Selecting by ID
<p>I have the ID of a selected textarea stored in a variable. Is it possible to use that variable to select the element by ID later on in the code? For example:</p>

<pre><code>var currentTextarea = null;

function foo() {
    currentTextarea = 'pageid'; // This will be set dynamically via an event. Example only.
}

function bar() {
    $('#' + currentTextarea).val(); // Although this don't seem to work
}
</code></pre>
