Answer the question
In order to leave comments, you need to log in
How can I make the first item in the list have focus?
There is a search script, it gives out the matched elements in a list. When you hover over an element , it acquires focus . But the app will only function with the virtual keyboard, no mouse. How to make the first element automatically in focus (this is necessary so that when you press the virtual enter key with emulate a click on it)
Here is the markup of the input:
<input id="myinput" type="text" class="form-control" placeholder="Введите слово для поиска" name="phone" required/>
$("#myinput").autocomplete({
minLength: 0,
source: projects,
focus: function (event, ui) {
$("#myinput").val(ui.item.label);
return false;
},
select: function (event, ui) {
$("#myinput").val(ui.item.label);
$("#myinput-id").val(ui.item.value);
$("#myinput-description").html(ui.item.desc);
$("#myinput-icon").fadeOut('slow', function () {
$(this).attr("src", "images/" + ui.item.icon).fadeIn('slow');
});
return false;
}
})
.data("autocomplete")._renderItem = function (ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.label + "<br>" + item.desc + "</a>")
.appendTo(ul);
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question