开发者

Keep focus on input when tab-selecting a jQuery autocomplete entry

http://jqueryui.com/demos/autocomplete/

Basically my issue is that when the user uses the tab key to select an item, the next form field gets the focus, but unless the input is empty, I want the focus to stay on the input.

$('.ui-autocomplete').keypress(开发者_开发问答function(event) {
    if(event.keyCode == '9') { // Tab
        console.log('test');
    }
});

I thought the above code might work (or doing the function on the actual li items generated by jQuery UI), but no dice.

Any ideas? I know I'm close but I just can't figure out what element I need to tie this to.


Figured out that I needed to use the same code I used before on the input, but use "keydown" instead of "keypress".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜