How to simulate loss and return of focus?

Actually, you need to build a crutch or somehow solve the problem. There is a code:

function ac_catch(el) {
    q = $("#" +;
        type: "POST",
        url: "ac.php",
        data: 'q=' + q + '&' + 'id=' +,
        success: function (html) {
            ac_data = html;
            $("#" +"\n"), {
                delay: 10,
                minChars: 1,
                matchSubset: 1,
                autoFill: false,
                maxItemsToShow: 15

Autocomplete is used on multiple inputs, and only fires after changing the focus to another and returning back again. Is it possible to somehow emulate the loss and return of focus, but so that the focus is not transferred to the input (well, I will make the extreme option hidden, although I don’t know if the event will work on it), or tell me where I’m a fool.)


And in general, has anyone come across the implementation of a different autocomplete for many inputs – can you suggest a working option?

Answer 1

jQuery(“#needs_to_be_active”).focus() – will give focus to the element with id=needs_to_be_active.

Consequently, the focus that was on the previous element will no longer be on it – cap.

DO NOT use this code to implement autocomplete at all!!! If you need to perform such “frauds”, then the question should involuntarily arise: “Am I doing everything right?”.

Hereis an example of AutoComplete as it is done in AjaxToolkit. Learn, use, enjoy! (ASP.NET)

Hereis another AutoComplete example. (PHP)

Answer 2

Solved the problem by using Jquery UI Autocomplete library. Campaign it turned out to be less buggy.

$( "#" ).autocomplete({source: String(ac_data).split("n")});