jQuery hover变得混乱了
希望有人能帮我解决jQuery中的奇怪问题。我有一个奇特的悬停正在进行的页脚导航,它闪烁,每当我悬停关闭,然后回到亚纳伏还没有完成它的过渡。下面是我从代码方面得到的信息 jQuery:jQuery hover变得混乱了,jquery,hover,jquery-hover,Jquery,Hover,Jquery Hover,希望有人能帮我解决jQuery中的奇怪问题。我有一个奇特的悬停正在进行的页脚导航,它闪烁,每当我悬停关闭,然后回到亚纳伏还没有完成它的过渡。下面是我从代码方面得到的信息 jQuery: if($('#ft_navi .nav').length > 0){ $('#ft_navi .nav ul').css('display', 'none'); /* if user doesn't have JS enabled, it will show everything for th
if($('#ft_navi .nav').length > 0){
$('#ft_navi .nav ul').css('display', 'none'); /* if user doesn't have JS enabled, it will show everything for the customer */
$("#ft_navi .nav > li").hover(function() {
$(this).find('ul').stop(true, true).show('slow');
},
function(){
$(this).find('ul').stop(true, true).hide('slow');
}); //end of hover
} /* end of footer */
以下是HTML:
<ul class="nav">
<li class="">
<a href="">Automotive</a>
<ul>
<li class=""><a href="">Overview</a></li>
<li class=""><a href="">Credit</a></li>
</ul>
</li>
</ul>
…只是让它快速打开和关闭
谢谢你的提示 因为如果不停止(如果元素已设置动画,则停止元素上的动画),它将绑定显示和隐藏您在元素上悬停的次数 解决此问题的一种方法是在悬停上添加延迟:
$(this).find('ul').show('slow');
if($('#ft_navi .nav').length > 0){
$('#ft_navi .nav ul').css('display', 'none'); /* if user doesn't have JS enabled, it will show everything for the customer */
$("#ft_navi .nav > li").hover(function() {
$(this).find('ul').stop(true,true).delay(300).show('slow');
},
function(){
$(this).find('ul').stop(true,true).delay(300).hide('slow');
}); //end of hover
} /* end of footer */