在我給出的例子中,我有兩個文本框。當第一個文本框中的值發生改變時,我想查找緊接着的下一個文本框(注意:無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);}); –