jQuery UI自动完成自动对焦不起作用 [英] jQuery UI Autocomplete autoFocus not working
问题描述
我正在使用jQuery UI自动完成功能,并尝试实现autoFocus选项.
I am using jQuery UI autocomplete and trying to implement the autoFocus option.
文档指出以下内容: 如果设置为true,则第一项将自动聚焦.
The documentation states the following: If set to true the first item will be automatically focused.
我创建了一个基本示例,但无法正常工作.我肯定想念一些明显的东西.参见此处: http://jsfiddle.net/9bQJX/
I created a basic example and cannot get to work. I must be missing something obvious. See here: http://jsfiddle.net/9bQJX/
$("#autocomplete").autocomplete({
source: [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
],
autoFocus: true
});
推荐答案
您正在使用旧版本的jQueryUI(1.8.9).该选项在1.8.16下可以正常工作.实际上,根据更改日志,在1.8.11中添加了autoFocus
选项,因此您应该任何版本> = 1.8.11都很好.
You're using an old version of jQueryUI (1.8.9). The option works fine with 1.8.16. In fact, according to the changelog, the autoFocus
option was added in 1.8.11, so you should be good with any version >= 1.8.11.
查看使用1.8.16更新的示例: http://jsfiddle.net/Bqujj/
这篇关于jQuery UI自动完成自动对焦不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!