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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里