Jquery Get Value of Previous Input Text Field
<p>I'm trying to alert a previous text field's value. Here's what I've tried so far but no dice:</p>

<pre><code>&lt;div&gt;
    &lt;input type="text" value="foo"&gt;
&lt;/div&gt;
&lt;div&gt;
    &lt;select onchange="alert($(this).prev('input').val())"&gt;
        &lt;option value="bar1"&gt;bar1&lt;/option&gt;
        &lt;option value="bar2"&gt;bar2&lt;/option&gt;
    &lt;/select&gt;
&lt;/div&gt;
</code></pre>
