一个Jquery弹出菜单无法收回
本帖最后由 walunwine4 于 2012-12-04 15:41:20 编辑
大家好。刚在网上下了一个弹出菜单的代码。看不太懂。他里面已经设置了fadeout但本地测试仍无法自动隐藏,希望可以帮忙整理一下.
希望能够实现鼠标离开弹出的菜单区域后3秒钟自动隐藏.谢谢了先
麻烦能够把您的方法结合到JS代码里.谢谢.
-------------HTML-----------------
<div style="position:relative" class="index_livesearchbox">
<form action="<{link ctl=search act=result}>" method="post" class="SearchBar" autocomplete="off">
<input style="margin:0 0 0 0px;padding:0;width:190px;font-weight:bold;text-align:center;color:#333;font-family:Georgia, 'Times New Roman', Times, serif;background:none;height:30px;" class="inputstyle keywords" name="name[]" type="text" value="Nom du Serveur" onfocus="this.value=''" onkeyup="lookup(this.value); " />
</form>
<div id="suggestions" style="z-index:3000;"></div>
</div>
-------------JS-----------------
<script>
$ES('#suggestions').setStyle('display','block');
$ES('#suggestions').fade('hide');
$ES('.living-input').addEvent('blur', function(){
$ES('#suggestions').fade('out');
});
function lookup(inputString) {
if(inputString.length == 0) {
$ES('#suggestions').fade('out');
//jQuery('#suggestions').fadeOut(); // Hide the suggestions box
} else {
var req = new Request({
method: 'post',
url: 'plugins/widgets/livingsearch/searchapi.php',
data: { 'queryString' : inputString ,
'lsIsCache': '<{$setting.lsIsCache}>',
'lsCacheTime':'<{$setting.lsCacheTime}>',
'lsIsCatalog':'<{$setting.lsIsCatalog}>',
'lsIsThumb':'<{$setting.lsIsThumb}>',
'lsIsGoodname':'<{$setting.lsIsGoodname}>',
'lsIsGoodprice':'<{$setting.lsIsGoodprice}>'
<{if $data['type_id'][0]=="_ANY_"}>,'lsTypeId':'any'<{else}>
,'lsTypeId':'<{foreach from=$data['type_id'] item=goodtype}><{$goodtype}>|<{/foreach}>'
<{/if}>
<{if $data['cat_id'][0]=="_ANY_"}>,'lsCatId':'any'<{else}>
,'lsCatId':'<{foreach from=$data['cat_id'] item=cattype}><{$cattype}>|<{/foreach}>'
<{/if}>
},
onRequest: function() { },
onComplete: function(response) {
$ES('#suggestions').set('html',response);
}
}).send();
$ES('#suggestions').fade('in'); // Show the suggestions box
}
}
</script>
-------------CSS-----------------
<style id="suggestionsStyle">
/* SEARCH FORM */
#suggestions{ position:absolute; margin-top:0px;left:-35px; width:<{$setting.lsBoxwidth}>px; display:none; margin-left: 0px;}
/* SEARCHRESULTS */
#searchresults { border-width:1px; border-color:#000; border-style:solid; width:260px; background-color:#<{$setting.lsCatabg}>; font-size:10px; line-height:14px; z-index:1000; position: absoulte;}
#searchresults a {padding-left:5px; display:block;color:#000; border-bottom:1px solid&n