I have a jquery search suggestions. The function is running ok. But now I want the function detect continue search.
Example : I want to search name David, I input in textbox just text : Da . And name suggestion will be show. Now if I click every where, div box suggestion will be close right ?.
and here what I want, when I back again click to textbox search, it will show div box suggestion last I input like the case : Da
Here is JS code so far :
$(document).ready(function() {
$(".searchs").keyup(function() {
var searchbox = $(this).val();
var dataString = 'searchword=' + searchbox;
if (searchbox == '') {
$("#display").hide();
} else {
$.ajax({
type: "POST",
url: "searchs.php",
data: dataString,
cache: false,
success: function(html) {
$("#display").html(html).show();
}
});
}
return false;
});
$(".searchs").blur(function() {
$("#display").hide();
});
});
Any idea ?
Here is how to display the suggestion div when the user clicks in the text box, if there is text in the text box.