如何使下拉自动完成消失onblur或在jquery中单击外部?

Bal*_*ala 3 jquery

下面是调用在搜索框中显示自动完成功能的函数...我希望自动完成消失在布尔上或在搜索框外单击...请告诉我应该在此函数中添加什么来使自动完成删除在外面点击时消失了吗?

function hideLoader(){
        $('#sub_cont').fadeIn(100);
        $('.search-background').fadeOut(100);
    };

    $('#search').keyup(function(e) {
      if(e.keyCode == 13) {
        showLoader();
        $('#sub_cont').fadeIn(100);
        $("#content #sub_cont").load("../ajax/search.php?val=" + $("#search").val(), hideLoader());
        }
      });

//Fading out the div when the text box is empty
    String.prototype.trim = function() {
    return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
        }

    $(".searcher").keyup(function(){

        if($('.searcher').val().trim().length > 0) {
            // is not empty
            showLoader();
            $('#sub_cont').fadeIn(100);
            $("#content #sub_cont").load("../ajax/search.php?val=" + $("#search").val(), hideLoader());
        } else {
            // is empty
            $('#sub_cont').fadeOut(100);
        }

    });
Run Code Online (Sandbox Code Playgroud)

Jas*_*son 6

这有点简单:

$('body').click( function() {
    $('.ui-autocomplete').hide('');

});
Run Code Online (Sandbox Code Playgroud)