Getting the previous sibling of an element using JQuery
<p>I have a page where i have multiple textboxes followed by a "browse" link, like this:</p>

<p>[textbox1] Browse<br/>
[textbox2] Browse<br/>
[textbox3] Browse<br/></p>

<p>Now I want to know which textbox's browse link I pushed. I want to set a global variable (how to do that in Javascript/JQuery?) and save the textbox, or at least the class/id/name of the textbox so that I know which textbox to manipulate from the browse routing.</p>

<p>I don't know the id or anything of the textbox since this is generated at run time.  All I know is that it's the previous sibling to the browse link.</p>

<p><strong>EDIT:</strong>
Cant get it to work, this is my jquery method, just for testing it:</p>

<pre><code>$(document).ready(function() {
    $('#BrowseLink').click(function() {
        alert($(this).prev('input[type=text]').attr('id'));
        return false;
    });
});
</code></pre>

<p>it makes an alert saying "undefined"...</p>

<p>This is my markup on the page:</p>

<pre><code>&lt;input id="Image"  name="Image" width="5px" type="text" value=""&gt;&lt;/input&gt;&amp;nbsp;&lt;a id="BrowseLink" href="#"&gt;Browse&lt;/a&gt;
</code></pre>

<p><strong>EDIT EDIT</strong>
Looking at my markup i solved it, the nbsp; is an entity aswell, hence the need for <code>prev().prev()</code></p>
