嗨,我有以下的html:的jQuery寻找元素旁边另一
<p>
<input type="text" name="field1"/> <input type="hidden" name="fieldh1"/>
<button type="button" class="sendInfo">Send</button>
</p>
<p>
<input type="text" name="field2" /> <input type="hidden" name="fieldh2"/>
<button type="button" class="sendInfo">Send</button>
</p>
我要的是,当用户点击该按钮,我需要使用Ajax场字段的内容发送。
这就是我想要做的没有成功。
$(function() {
$('button.sendInfo').live('click', function() {
var id = $(this).parent().next('[type=text]').val();
alert(id);
});
});
我打算设置从AJAX调用到正常的文本框收到什么文本框的用户类型的隐藏字段和值。但问题是,我甚至无法获得与用户点击的按钮位于同一行的文本框的值。 任何人都可以帮助我吗? 非常感谢。
是的! This works fine: $(this).parent()。find('[type = text]')。val(); 感谢您的帮助 – thiagoleite 2010-05-20 19:44:04
找到只有在两者之间没有任何作品.. – stuartdotnet 2013-08-23 04:51:51