Javascript JS导航文本框控件

Javascript JS导航文本框控件,javascript,jquery,Javascript,Jquery,基本上,我尝试在与excel几乎相同的文本框中导航。以下是迄今为止我能找到的代码: <script type='text/javascript'>//<![CDATA[ $(window).load(function(){ $(document).ready(function () { $('input').keyup(function (e) { var input = $(this), td = input.closest(

基本上,我尝试在与excel几乎相同的文本框中导航。以下是迄今为止我能找到的代码:

<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){
$(document).ready(function () {
    $('input').keyup(function (e) {
        var input = $(this),
            td = input.closest("td"),
            next;

        switch (e.which) {
            case 37: next = td.prev().find("input"); break;
            case 39: next = td.next().find("input"); break;
            case 38: next = input.closest("tr").prev().find("td:eq(" + td.index() + ")").find("input"); break;
            case 40: next = input.closest("tr").next().find("td:eq(" + td.index() + ")").find("input"); break;

        }

        if (next) {
            next.focus();
        }
    });
});

});//]]>  

</script>
我遇到的问题是,当我按下下面一行的enter键时,它会向下移动两个文本框,而不是只移动1个文本框

案例40:next=input.closesttr.next.findtd:eq+td.index+findinput;中断

此外,它仅适用于键盘右侧的“回车”按钮

代码/源代码可在此处找到:

这个键代码代表箭头,而不是回车-检查。。如果你需要输入,你可以只添加第13行:在第40行之前。是的,我很抱歉,我忘了包括我为输入所做的更正/添加的行,但结果仍然是它下降了两次。你的HTML无效;a不能是除a之外的任何元素的后代,或者您可以包装的内部。