【问题标题】:Jquery Autofocus second inputJquery自动对焦第二输入
【发布时间】:2017-07-14 17:36:37
【问题描述】:

我找到了一种使用 jquery 将下一个输入集中在表单中的方法。但是我必须在表单中的每个输入之后添加隐藏输入。所以这个 jquery 函数专注于下一个隐藏的输入。我怎样才能通过这个隐藏的输入?

$(function() {
    $('#fill1,#fill2,#fill3,#fill4,#fill5,#fill6').keyup(function(e) {
        if ($(this).val().length == $(this).attr('maxlength')) {
            $(this).next(':input').focus();
        }
    })
});

【问题讨论】:

    标签: jquery forms autofocus


    【解决方案1】:

    你可以通过加倍下一个函数来跳过一个:

    $(this).next(':input').next(':input').focus();
    

    Here is jfiddle.

    【讨论】:

      猜你喜欢
      • 2022-08-16
      • 2013-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-05
      • 2018-11-24
      • 2017-06-11
      • 1970-01-01
      相关资源
      最近更新 更多