gpt4 book ai didi

javascript - 如何通过按回车键关注同一列中的下一行输入

转载 作者:行者123 更新时间:2023-11-28 03:19:09 25 4
gpt4 key购买 nike

我正在保存纸张结果,我想像在 MS Excel 中那样通过按 Enter 键进行焦点快速保存它在下一个底部单元格上

<tr>
<td>1</td>
<td>Muhammad Umar Abdur Rahman</td>
<td>
<input type="text" value="0" name="ReadingMarks257" onkeydown="Next(event)" class="input">
</td>
<td>
<input type="text" value="0" name="WritingMarks257" onkeydown="Next(event)" class="input">
</td>
<td>
<input type="text" value="0" name="PaperMarks257" onkeydown="Next(event)" class="input">
</tr>
<tr>
<td>2</td>
<td>Muhammad Abu Bakkar</td>
<td>
<input type="text" value="0" name="ReadingMarks258" onkeydown="Next(event)" class="input">
</td>
<td>
<input type="text" value="0" name="WritingMarks258" onkeydown="Next(event)" class="input">
</td>
<td>
<input type="text" value="0" name="PaperMarks258" onkeydown="Next(event)" class="input">
</td>
</tr>

我已经尝试过

function Next(e) {
if (e.which === 13) {
var Element = $(this).closest('tr').next().find('.input');
Element.focus();
} else {
$("#Msg").html('another Pressed');
}
}

最佳答案

您可以使用nextElementSibling.focus():

function Next(e) { 
if (e.which === 13) {
e.target.nextElementSibling.focus();
}
else {
$("#Msg").html('another Pressed');
}
}

关于javascript - 如何通过按回车键关注同一列中的下一行输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59333919/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com