Jquery Hover闪烁问题 [英] Jquery Hover Flickering issue
问题描述
http:// jsfiddle .net / kr9pY / 7 /
在这个演示中,当我们将id悬停在div上时,你可以看到id =container,一个div为class = nav淡入。但问题是,在这样做之后,如果我将div悬停在带有class =nav的div上,div会逐渐淡出并再次出现,如果我将光标稍微移动到.nav div中,它会反复重复此行为。当我们将鼠标悬停在此div中的.nav div或mover光标时,我不想这种行为。
谢谢,对不起我的英语不好。
尝试
$(文件) .ready(function(){
$(#containerNav)。hover(
function(){$('。nav')。stop(true,true).fadeIn( );},
function(){$('。nav')。stop(true,true).fadeOut();}
);
});
取自 http://api.jquery.com/stop/
我更改了标记以添加包含div以阻止鼠标离开被叫。
< div id =containerNav>
< div class =nav>< a class =prevhref =#> Prev< / a> < a class =nexthref =#> Next< / a> < / DIV>
< div id =container>
容器中的一些内容
< / div>
< / div>
现在当你将鼠标悬停在控件上时,你没有做一个导致眨眼的鼠标离开。
Hope u people will be fine. Here is my basic code:
in this demo you can see when we hover on div with id="container", a div with class="nav" fades in. But the problem is that after doing this if i hover on div with class="nav" the div fades out and in again, and if i mover cursor slightly within .nav div, it repeats this behavior repeatedly. I don't want to this behaviour when we hover on .nav div or mover cursor within this div.
Thank, and sorry for my bad english.
Try
$(document).ready(function(){
$("#containerNav").hover(
function() { $('.nav').stop(true, true).fadeIn(); },
function() { $('.nav').stop(true, true).fadeOut(); }
);
});
Taken from http://api.jquery.com/stop/
I changed the markup to add a containing div as well which stops a mouse leave being called.
<div id="containerNav">
<div class="nav"><a class="prev" href="#">Prev</a> <a class="next" href="#">Next</a> </div>
<div id="container">
Some Content in Container
</div>
</div>
Now when you hover over the controls your not doing a mouseleave which causes the blink.
这篇关于Jquery Hover闪烁问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!