Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
清除Php Live MySQL数据库搜索的结果Div(非输入字段)_Php_Mysql_Ajax - Fatal编程技术网

清除Php Live MySQL数据库搜索的结果Div(非输入字段)

清除Php Live MySQL数据库搜索的结果Div(非输入字段),php,mysql,ajax,Php,Mysql,Ajax,对不起,我一定错过了一些非常基本的东西。我想在搜索后清除results DIV。我可以用一个按钮,或者更好的是,当输入字段被清除时。当前,如果使用此重置按钮,输入字段将重置,但结果DIV仍保留在屏幕上 $(文档).ready(函数(){ $('.search box input[type=“text”]')。打开(“键控输入”,函数(){ /*获取更改时的输入值*/ var term=$(this.val(); var resultDropdown=$(this.sillides(“.resu

对不起,我一定错过了一些非常基本的东西。我想在搜索后清除results DIV。我可以用一个按钮,或者更好的是,当输入字段被清除时。当前,如果使用此重置按钮,输入字段将重置,但结果DIV仍保留在屏幕上

$(文档).ready(函数(){
$('.search box input[type=“text”]')。打开(“键控输入”,函数(){
/*获取更改时的输入值*/
var term=$(this.val();
var resultDropdown=$(this.sillides(“.result”);
if(期限长度){
$.get(“incl_php/backend search.php”,{query:term}).done(函数(数据){
//在浏览器中显示返回的数据
html(数据);
});
}否则{
resultDropdown.empty();
}
});
//单击结果项时设置搜索输入值
$(document).on(“click”,“.result p”,function()){
$(this.parents(“.search box”).find('input[type=“text”]).val($(this.text());
$(this.parent(“.result”).empty();
});
});
$(“#重置”)。在(“单击”,函数(){
$(“.result”).empty();
});

试验
检查此示例(相应地检查并调整代码的其余部分):-

$('.search box input[type=“text”]')。打开(“键控输入”,函数(){
var term=$(this.val();
var resultDropdown=$(this.sillides(“.result”);
if(期限长度){
html(术语);
}否则{
resultDropdown.html(“”);
}
});
//单击结果项时设置搜索输入值
$(document).on(“click”,“.result p”,function()){
$(this.parents(“.search box”).find('input[type=“text”]).val($(this.text());
$(this.parent(“.result”).html(“”);
});
$(“#重置”)。在(“单击”,函数(){
$(“.result”).html(“”);
});


而不是
empty()
使用
.html(“”)
和checktry
$(this.parent().find(“.result”).empty()我更新了您的问题以查看是否存在问题。我无法验证一个,这在我看来是正确的。你忘了包含jQuery脚本了吗?@milwaukee66很高兴能帮助你。