I'm trying to create an autocompleter and I want to create an else if statements.
here is my logic. Bind a "keyup" event to the input (and receive the "event object" as e). In the event:
Can anyone help me get this right? I would greatly appreciate it. I'm getting frustrated because I don't know what to do.
- var searchText = $("#searchtext").keyup(function(e) {
console.log(test , 'keyup1')
if ($(this).val().length < 2){
var test = $("#searchresults").fadeOut("slow");
console.log(test , 'fadeOut')
} else if ( e.which === 38 ) {
searchText();
} else if ( e.which === 40 ) {
searchText();
} else if ( e.which === 13 ) {
searchText();
} else if ( e.which === 27 ) {
searchText();
} else {
}
return false
});