如何专注于创建的自动完成菜单项:
<ul id="ui-id-1" class="ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all" tabindex="0" ...>
<li class="ui-menu-item" role="presentation">
<a id="ui-id-3" class="ui-corner-all" tabindex="-1">ONE</a>
<li class="ui-menu-item" role="presentation">
<a id="ui-id-4" class="ui-corner-all" tabindex="-1">TWO</a>
<...>
我试过$('#ui-id-3').focus();
没有效果。 通常我的意思是自定义自动完成: https://forum.jquery.com/viewImage.do?fileId=14737000004279180&forumGroupId=14737000000003003
答案 0 :(得分:1)
试试这段代码:
$("#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
});