在输入键移动到表格中的下一个单元格 [英] On enter key move to next cell down in a table

查看:97
本文介绍了在输入键移动到表格中的下一个单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个表单,如果按下串行列上的回车键,下面的单元格将被选中。有人可以为这个任务解决正确的jquery公式吗?

I am trying to create a form where, if you press enter key on the serial column, the cell below becomes selected. Can someone please solve the correct jquery formula for this task?

我正在尝试

$('.serial').keypress(function(e) {
    console.log(this);
    if (e.which == 13) {
        $(this).nextAll('#serial').first().focus();
        e.preventDefault();
    }
});

http://jsfiddle.net/tYFcH/4/

推荐答案

$('.serial').keypress(function(e) {
    console.log(this);
    if (e.which == 13) {
        $(this).closest('tr').next().find('input.serial').focus();
        e.preventDefault();
    }
});

http://jsfiddle.net/tYFcH/6/

这篇关于在输入键移动到表格中的下一个单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆