【发布时间】:2010-12-22 18:06:48
【问题描述】:
我是 jquery 的新手。 我正在更改输入文本的值,我需要更改下一个输入文本的值,所以我的代码是:
$(document).ready(function() {
$('[type=text]').change(function() {
$(this).next('input').val("newvalue");
});
});
但是什么都没有……!
编辑:从下面的评论中发布 HTML
<form method="post" action="/volume/create">
<table>
<tr>
<th><label for="volume_h1">H1</label></th>
<td><input type="text" id="volume_h1" name="volume[h1]"></td>
</tr>
<!-- .............. to volume_h24 -->
<tr>
<th><label for="volume_h24">H24</label></th>
<td><input type="text" id="volume_h24" name="volume[h24]"></td>
</tr>
</table>
</form>
【问题讨论】:
-
输入是否直接位于处理程序附加到的输入旁边?如果没有,你需要
nextAll() -
你也应该发布相关的html。