Hello everyone!
Consider this code:
<fieldset>
<label>
<span>
<span class="fieldinfo"></span>
<input type="text" name="name" />
</span>
Navn:
</label>
<label>
<span>
<span class="fieldinfo"></span>
<input type="text" name="phone" />
</span>
Telefon:
</label>
(...)
</fieldset>
When blurring one of the input fields, I want jQuery to load an URL into the
<span class="fieldinfo"></span> just before the input-field, with the value
of the blurred input field sent as parameter.
My current solution is based on counting the position of an input element
$("*").each(function(i){
if ($(this).is("input[@name=phone"))
phone_pos = i;
}
and later reacting on that:
$("*").eq(phone_pos).blur(function(){
$("*").eq(phone_pos-1).load("/phonelookup", {value :
$("*").eq(phone_pos).val()});
But I feel that it's a very ugly implementation, with many weaknesses. First
of all, it loops through all elements on the site. Secondly, it breaks, if
there are more tags in the site loaded by Ajax.
Any better ideas?
Best regards,
Søren Haagerup
--
View this message in context:
http://www.nabble.com/Accessing-span-before-input-tf2928666.html#a8187886Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
discuss@jquery.comhttp://jquery.com/discuss/