Reputation: 313
How do I focus on the created autocomplete menu item:
<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>
<...>
I've tried to $('#ui-id-3').focus();
Have not effect. Generaly i mean custom autocomplete: https://forum.jquery.com/viewImage.do?fileId=14737000004279180&forumGroupId=14737000000003003
Upvotes: 1
Views: 1794
Reputation: 638
Try this code:
$("#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
});
Upvotes: 1