How to Delay jQuery Live Search Without Having to Take Focus Off Input
<p>I am using the <a href="http://kilianvalkhof.com/2010/javascript/how-to-build-a-fast-simple-list-filter-with-jquery" rel="nofollow">live search code snippet</a> like some others may be. I have modified it for my needs but every time I try to add a delay to the <a href="http://api.jquery.com/keyup/" rel="nofollow">keyup</a> it will not search as I type; you must click out of the input box first. <em>Then</em> it displays results, which is not the point of live searching.</p>

<pre><code>var timeout = undefined;
    $(input).change( function() {
            var query = $(this).val();
            var idArray = getIds($(".instTable, .break"));
            //alert(idArray);
            if(query != ""){
                    //alert("made it");
                    var i = 0;
                    for(i; i &lt; idArray.length; i++){
                            $("#"+idArray[i]).find("th:not(:Contains(" + query + "))").closest($(".instTable, .break")).hide();
                            $("#"+idArray[i]).find("th:Contains(" + query + ")").closest($(".instTable, .break")).show();
                    }
            }
            else{
                    //alert("skipped");
                    for(var i = 0; i &lt; idArray.length; i++){
                            $("#"+idArray[i]).find("th").closest($(".instTable, .break")).show();
                    }
            }
    }).keyup(function() {
       if(timeout != undefined) {
       clearTimeout(timeout);
     }
    var timeout = setTimeout(function() {
     timeout = undefined;
      $(this).change();
     }, 900);

    });
</code></pre>
