您好,欢迎来到知库网。
搜索
您的当前位置:首页html标签outclick,html - Jquery - Click outside and Hide Div - Stack Overflow

html标签outclick,html - Jquery - Click outside and Hide Div - Stack Overflow

来源:知库网

If you look at the source code of your example ;

$(document).click(function(){

$('.ddcontainer > div > ol').hide();

});

This hides the div when there has been a click on the document.

Give you div an ID like so:

and then:

$(document).click(function(){

$('#searchResults').hide();

});

Alternatively and maybe a better solution is to use focus and blur:

$("#kwd_search").focus(function(){

$('#searchResults').show();

}).blur(function(){

$('#searchResults').hide();

});

This will show the results when the focus is put onto the input, and removes it when you 'leave' the input.

UPDATE

With the autocomplete plugin, you can perform a task after the item has been selected like this:

$( "#tags" ).autocomplete({

source: availableTags

}).bind( "autocompleteselect", function(event, ui) {

location.href = ui.item.value; // If the value of the item is a url, this will forward you to it

});

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- zicool.com 版权所有 湘ICP备2023022495号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务