jquery自动完成 - 是否可以设置以便下拉显示在焦点上?

时间:2010-12-20 20:37:46

标签: jquery-ui jquery-ui-autocomplete

  

可能重复:
  jQuery autocomplete UI- I'd like it to start the search onfocus without the user having to type anything

我注意到了这个问题

jQuery autocomplete UI- I'd like it to start the search onfocus without the user having to type anything

我有同样的问题,我在解决方案中也遇到了同样的问题。

基本上,我正在尝试强制jquery自动完成UI在焦点上执行,而不是要求用户按任意键或输入任何值。

感谢

1 个答案:

答案 0 :(得分:1)

您使用的是哪个版本的jQueryUI?根据自动完成的文档,您引用的方式应该起作用:

(“搜索”方法文档)

  

...如果未指定value参数,则使用当前输入的值。可以使用空字符串和minLength:0来调用,以显示所有项目。

我在这里发布了一个适用于FF / Chrome的示例:http://jsfiddle.net/andrewwhitaker/B38Hj/。如果你看到任何奇怪的行为,请告诉我。

$("input").focus(function() {
    $(this).autocomplete("search");
});

该示例使用jQuery UI 1.8.5和jQuery 1.4.4。

相关问题