Enterキーを押すと、クラスの次の入力が選択される関数を作成しようとしています。
同じ行内の次の要素を.focus()することができました。ただし、次の行で次の入力を選択する必要がある場合、続行できません。
次の行の最初の.quantityテキストボックスにフォーカスする必要があります。
コンソールにエラーはありません。
HTML
<table>
<tr>
<td>
<input class='quantity' value=''/>
<input class='100' value=''/>
</td>
<td>
<input class='quantity' value=''/>
<input class='50' value=''/>
</td>
<td>
<input class='quantity' value=''/>
<input class='20' value=''/>
</td>
</tr>
<tr>
<td>
<input class='quantity' value=''/>
<input class='100' value=''/>
</td>
<td>
<input class='quantity' value=''/>
<input class='50' value=''/>
</td>
<td>
<input class='quantity' value=''/>
<input class='20' value=''/>
</td>
</tr>
</table>
JQuery
$(".quantity").on('keypress', function (e) {
if (e.keyCode === 13) {
$(this).parent().next('td').find('input.quantity').focus();
}
});