How do I move focus to next input with jQuery?

后端 未结 15 1818
不思量自难忘°
不思量自难忘° 2020-12-04 09:32

I am using the autocomplete plugin with jQuery and it is working fine. However, in IE, when the user selects an item in the autocomplete, the focus does not then move to the

相关标签:
15条回答
  • 2020-12-04 10:36

    Try using something like:

    var inputs = $(this).closest('form').find(':focusable');
    inputs.eq(inputs.index(this) + 1).focus();
    
    0 讨论(0)
  • 2020-12-04 10:36
    var inputs = $('input, select, textarea').keypress(function (e) {
      if (e.which == 13) {
        e.preventDefault();
        var nextInput = inputs.get(inputs.index(this) + 1);
        if (nextInput) {
          nextInput.focus();
        }
      }
    });
    
    0 讨论(0)
  • 2020-12-04 10:37

    why not simply just give the input field where you want to jump to a id and do a simple focus

    $("#newListField").focus();
    
    0 讨论(0)
提交回复
热议问题