Javascript 按enter键移动到表中的下一个单元格
我正在尝试创建一个表单,如果您在序列列上按enter键,下面的单元格将被选中。有人能为这个任务解决正确的jquery公式吗 我正在努力Javascript 按enter键移动到表中的下一个单元格,javascript,jquery,Javascript,Jquery,我正在尝试创建一个表单,如果您在序列列上按enter键,下面的单元格将被选中。有人能为这个任务解决正确的jquery公式吗 我正在努力 $('.serial').keypress(function(e) { console.log(this); if (e.which == 13) { $(this).nextAll('#serial').first().focus(); e.preventDefault(); } }); 如果在任何输
$('.serial').keypress(function(e) {
console.log(this);
if (e.which == 13) {
$(this).nextAll('#serial').first().focus();
e.preventDefault();
}
});
如果在任何输入中按enter键时要移动到下面的单元格,请使用以下命令:
$('table input').keypress(function(e) {
if (e.keyCode == 13) {
var $this = $(this),
index = $this.closest('td').index();
$this.closest('tr').next().find('td').eq(index).find('input').focus();
e.preventDefault();
}
});
这是你的小把戏:下一个dom插件就是为此编写的。免责声明:是我写的
“#串行”!=”。串行'
是否可以进行循环?
$('table input').keypress(function(e) {
if (e.keyCode == 13) {
var $this = $(this),
index = $this.closest('td').index();
$this.closest('tr').next().find('td').eq(index).find('input').focus();
e.preventDefault();
}
});
$('.serial').keypress(function(e) {
if (e.which == 13) {
$(this).nextInDOM('.serial').focus();
}
});