Remove autosuggest text when clicking off field

I have just finished adding a search bar into my page. It pretty much all works fine, however, I would like the autosuggestions to disappear after clicking outside of the field. How would I do this? I am using HTML5 and my codes are: $(document) .ready(function() { $('.autosuggest').keyup(function() { var search_term = $(this).val(); $.post('search.php', {search_term:search_term}, function(data) { $(".result").html(data); $('.result li').click(function() { var result_value = $(this).text(); $('.autosuggest').val(result_value); $('.result').html(''); }); }); }); }); Not too sure my php is needed but just in case... ', $row['town'], ''; } } ?>

以上就是Remove autosuggest text when clicking off field的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准