I am working on dynamic search.
When I write in the #search
input, I want to hide the div #Main
and display the div #search_list
. And when I delete what i wrote in the search bar by pressing Ctrl+A & Backspace, the #search_list
should hide and the #Main
div should be displayed again.
Right now, when I press Ctrl+A & Backspace, the div #search_list
is not hidden.
$(document).ready(function(){
$("#search").keyup(function(){
var str= $("#search").val();
if(str == '') {
$( "#Main" ).show();
$( "#search_list" ).hide();
} else{
$.get( "{{ url('home?id=') }}"+str, function( data ) {
$("#Main").hide();
$( "#search_list" ).show().html( data );
});
}
});
});