views:

333

answers:

3

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 next input field. Naturally it works in Firefox. The plugin doesn't have a built-in solution but does provide for "options". Is there a way I can force it to move to the next input field?

A: 

Could you post some of your HTML as an example?

In the mean-time, try this:

$('#myInput').result(function(){
    $(this).next('input').focus();
})

That's untested, so it'll probably need some tweaking.

Sam
@c0mrade That's not what I meant.
Sam
+1  A: 

What Sam meant was :

$('#myInput').focus(function(){
    $(this).next('input').focus();
})
c0mrade
+1  A: 

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.

Nick Craver