我正在开发一个 jQuery 下拉菜单,当您将鼠标悬停在顶级项目上时会淡入。我想设置它,以便当您将鼠标移开时,菜单不会立即消失。我有这个代码:
$(document).ready(function(){
$('ul#menu > li').hover(
// mouseover
function(){
$(this).find('>ul').fadeIn('fast');
},
// mouseout
function(){
setTimeout( function(){
alert('fadeout');
$(this).find('>ul').fadeOut('fast')
}, 1000 );
}
);
});
一秒钟后,警报发生,但菜单没有淡出。