weixin_33712881 2019-01-11 10:57 采纳率: 0%
浏览 21

垂直关注文本框

i need to focus textbox in verticle by press enter key

first row and then second row then third row

here My script,

$(document).ready(function() {
    $(".vertical_row1").keypress(function(event) {
        if(event.keyCode == 13) { 
        textboxes = $("input.vertical_row1");
        debugger;
        currentBoxNumber = textboxes.index(this);
        if (textboxes[currentBoxNumber + 1] != null) {
            nextBox = textboxes[currentBoxNumber + 1]
            nextBox.focus();
            nextBox.select();
            event.preventDefault();
            return false 
            }
        }
    });
})
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table>
    <tr>
        <td><input class="vertical_row1" type="text" name="" value="" placeholder=""></td>
        <td><input class="vertical_row2" type="text" name="" value="" placeholder=""></td>
    </tr>
    <tr>
        <td><input class="vertical_row1"  type="text" name="" value="" placeholder=""></td>
        <td><input class="vertical_row2" type="text" name="" value="" placeholder=""></td>
    </tr>
<table>

</div>
  • 写回答

2条回答

      报告相同问题?

      悬赏问题

      • ¥15 macOS使用IDEA 2022.2.4打包JDK6项目报错
      • ¥20 OpenCV-Python简单轮廓寻找
      • ¥20 使用matlab进行含参数的最优化求解及数值模拟
      • ¥20 MATLAB找出一维变量中的局部极大值和局部极小值,并进行运算
      • ¥15 有Chang求三维杆单元几何非线性分析matlab代码
      • ¥50 使用unity easyar录屏功能。录屏视频整体色调很暗
      • ¥50 pyinstaller 打包问题
      • ¥15 无法使用cnssc调取网页数据
      • ¥15 Pycharm安装en_core_web_sm失败出现Could not find a version that satisfies the requirement spacy报错
      • ¥15 Python社区划分