在我给出的例子中,我有两个文本框。当第一个文本框中的值发生改变时,我想查找紧接着的下一个文本框(注意:无ID)并更改其值。如何使用jquery查找下一个元素?
给出的示例仅包含单个文本框组。实际上它可以是多个文本框。 (从&组到财务数据的文本框)
所以,当从文本框(txtFinancialYearFrom)中的值改变时,我想要找到到文本框(txtFinancialYearTo)并更改其值。
在此先感谢您的帮助!
<table class="fotm-table">
<tr>
<td class="text-right" width="120">
<span id="ContentPlaceHolder1_lblFinancialYear">Financial Data :</span>
</td>
<td>
<span>
<input type="text" id="txtFinancialYearFrom"
name="ctl00$ContentPlaceHolder1$txtFinancialYearFrom">
</span>
</td>
<td width="20" align="center">
<span style="align-content: center">to</span>
</td>
<td>
<span>
<input type="text" id="txtFinancialYearTo"
name="ctl00$ContentPlaceHolder1$txtFinancialYearTo">
</span>
</td>
</tr>
</table>
鉴于其他输入有一个'id',你可以不直接选择它,而不需要遍历DOM,'$('#txtFinancialYearTo'')'? –
如果它是一个组,那么ID应该是唯一的。 –
你试过谷歌吗? https://api.jquery.com/next/实际上是第一个链接,如果你谷歌“jquery下一个元素”,你可能会想要像$(“输入”)。 。下一个( '输入')VAL($(本).VAL()+ 1);}); –