jquery find element next to another
Posted
by Thiganofx
on Stack Overflow
See other posts from Stack Overflow
or by Thiganofx
Published on 2010-05-20T19:29:26Z
Indexed on
2010/05/20
19:40 UTC
Read the original article
Hit count: 118
jQuery
Hi I have the following html:
<p>
<input type="text" name="field2" /> <input type="hidden" name="fieldh2"/>
<button type="button" class="sendInfo">Send</button>
</p>
What I want is that when user clicks the button, I need to send using ajax the contents of the field field.
This is what i'm trying to do with no success.
$(function() {
$('button.sendInfo').live('click', function() {
var id = $(this).parent().next('[type=text]').val();
alert(id);
});
});
I plan to set what the user types in textbox to the hidden field, and the value received from the ajax call to normal textbox. But the problem is that i can´t even get the value of the textbox that is in the same line as the button the user clicks. Can anyone help me? Thanks a lot.
© Stack Overflow or respective owner