How do I move focus to next input with jQuery?

后端 未结 15 1815
不思量自难忘°
不思量自难忘° 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:16

    You can do something like this:

    $("input").change(function() {
      var inputs = $(this).closest('form').find(':input');
      inputs.eq( inputs.index(this)+ 1 ).focus();
    });
    

    The other answers posted here may not work for you since they depend on the next input being the very next sibling element, which often isn't the case. This approach goes up to the form and searches for the next input type element.

提交回复
热议问题