When I click the tab button for the first time, it works and the tab is prevented, however, if I click it again right away, it does not fit by default, and I exit the input field.
If I print something, then insert a tab, then enter something else, and then a tab, and then by default it will be prevented every time
The problem is that I cannot insert a tab into a row twice. Any idea what could be the problem?
$("#functionSearch").on("change propertychange keyup",function( event ) { event.preventDefault(); console.log(event) if (event.which == 9 ) { console.log("TAB") }else{ clearHighlight(); var input = $(this).val(); if(input.length > 0){ filteredArr = jQuery.grep(linksArr, function( val, index ) { return ( val.toLowerCase().indexOf(input.toLowerCase()) != -1); }); selectElements(filteredArr); } } }); // MAY BE USEFUL function selectElements(filteredArr){ $(filteredArr).each(function( index, link){ var id = link.split("~")[1] $("#"+id).addClass("selected"); }); highlightFirstElement(); } function highlightFirstElement(){ $(".selected").first().addClass("highlighted"); } function highlightNextElement(){ $(".selected").next().addClass("highlighted"); } function clearHighlight(){ $(".highlighted").removeClass("highlighted"); $(".selected").removeClass("selected"); } <div id="functionSearchDiv" class="funSearch"> <input type="text" id="functionSearch"></input> </div>
source share