提示后,jquery自动完成删除焦点 [英] jquery autocomplete remove focus after suggest

查看:101
本文介绍了提示后,jquery自动完成删除焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在自动完成列表中选择一个项目后,我的脚本将验证选择,但不会释放焦点。我甚至试图把焦点放在另一个元素上,让我失望。



这是我的代码:

  var usernames = [ $(#suggest1)。autocomplete(usernames); 
$(#suggest1)。result(function(){
$(this).submit();
setTimeout(function(){
$('#focusdiv ').focus();
},1);
});

有什么建议?

解决方案

#suggest1\" )自动完成(用户名)。
$(#suggest1)。result(function(){
$(this).submit();
setTimeout(function(){
$('。next -step')。focus();
},1);
});

注意:没有setTimeout函数,它不起作用。
'.next-step'是一个可点击的href(标签形式)

After selecting an item in the autocomplete list, my script validates the selection but does not release the focus. Ive even tried to place focus on another element to my dissapointment.

This is my code:

var usernames = [<? print_r($jquery_usernames); ?>];
            $("#suggest1").autocomplete(usernames); 
            $("#suggest1").result(function() {
                    $(this).submit();
                    setTimeout(function() {
                      $('#focusdiv').focus();
                    }, 1);                  
                });

Any suggestions?

解决方案

This is interesting and works (the focus is removed from the suggest1 input):

$("#suggest1").autocomplete(usernames); 
        $("#suggest1").result(function() {
                $(this).submit();                   
                setTimeout(function() {
                  $('.next-step').focus();
                }, 1);                  
            });

Note: It doesnt work without the setTimeout function. '.next-step' is a clickable href (tabbed form)

这篇关于提示后,jquery自动完成删除焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆