[jQuery] Traversing - finding previous input (Beginner question)

[jQuery] Traversing - finding previous input (Beginner question)


Apologies in advance for troubling the group with this. I have spent
some time on it in the documentation and cannot find the answer. I've
tried prev and +.
I want to select an input on a form to add in a link to display help
text. I have this working OK, but cannot position the link where I
want it. The 'helplink' (see script below) goes before the <div
class="help"> BUT I want it after the <input...>.
HTML BEFORE MODIFICATION:


<span class="question"><label for="name1">Name of your centre</label></
span>

<input name="name1" type="text" id="name1" size="50">





<div class="help">


Use the name you would like to be referred to when the data is
collected



</div>
MY SCRIPT:
$(document).ready(function() {
    // HTML for help link
    var helpLink = '<span class="show"><img src="..\/i\/blank.gif"
alt="Help" align="absmiddle"> <\/span>';
    // find insert point and add link
    $("div.help").before( helpLink );
    // hide help divs
    $('div.help').hide();
    // add onclick to show/hide help div
    $('span').click(function() {
        $(this).next().slideToggle('fast');
        $(this).toggleClass("hide");
        });
});
HTML WANTED:


<span class="question"><label for="name1">Name of your centre</label></
span>

<input name="name1" type="text" id="name1" size="50">
<span class="show"><img src="../i/blank.gif" alt="Help"
align="absmiddle"> </span>







<div class="help">


Use the name you would like to be referred to when the data is
collected



</div>
Many thanks