ds78662302 2014-02-08 17:50
浏览 24
已采纳

当值被删除时,如何清除自动建议div的内部结果?

Following is my auto suggest code created using jquery

$(document).ready(function(){
$(".input_search").keyup(function() 
{
var finder = $(this).val();
var queryString = 'key_wrd='+ finder;
if(finder==''){//check if search is empty}
else
{
 $.ajax({
 type: "POST",
 url: "searcher.php",
 data: queryString, 
 cache: false,
 success: function(html)
 {
  $(".display_found_query_cont").fadeIn();
  $(".display_found_query-window").append(html);
 }
 });
 }return false; 
 });
 });

This code closes the suggest window and clears the enterse text

$(document).mouseup(function (e)
{
var search_res_container = $(".display_found_query_cont");
if (!search_res_container.is(e.target)&& search_res_container.has(e.target).length === 0)
{
 search_res_container.fadeOut().html();
 $(".search_field").val('');
}
});

what do i want to do ?

I want the results displayed to be cleared when the text entered is erased So how do i do that?

  • 写回答

1条回答 默认 最新

  • duangewu5234 2014-02-08 18:13
    关注

    try this code:

    if(finder=='')
    {
      //check if search is empty
      $(".display_found_query-window").html('');
    }
    

    As per your comment, you want to replace the old content with new result. So just chnage the below line in your ajax success.

    $(".display_found_query-window").html(html);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟