Reputation: 439
Using the jQuery UI autocomplete, is there any way to automatically select the first item on TAB click (or at least stimulate a down key)?
Upvotes: 1
Views: 508
Reputation: 3242
You can use below jQuery for this:
$("#tags").on('keydown', function (e) {
var keyCode = e.keyCode || e.which;
if (keyCode == 9) {
//if alt pressed
e.preventDefault();
var _firstitem = $(".ui-autocomplete .ui-menu-item").first().text();
$(this).val(_firstitem);
}
});
Please have a look on this fiddle:
https://jsfiddle.net/mv38yozx/
Hope it will help you.
Upvotes: 1