需要修复 JQuery .hover() 并停止循环
使用 JQuery 悬停时遇到问题。看看这就是我想要做的,我希望能够将鼠标悬停在 div 上并隐藏背景图像并在其上显示一个新的 div (我有我想要显示为绝对的 div,所以没有问题),我可以隐藏 div,但在鼠标移动时无法将其恢复,这是我的代码
$('.div_to_hide').hover(function() {
var $this = $(this);
$this.stop().fadeTo('slow', 0.5, function(){
$('.div_to_appear').fadeIn('slow');
});
}, function(){
var $this = $(this);
$this.stop().fadeTo('slow', 1.0, function(){
$('.div_to_appear').fadeOut('fast');
});
});
希望有人可以帮助我解决这种情况。它让我不断地进出循环:(
感谢您一如既往的帮助
Well have an issue using JQuery hover. Look this is what I want to do, I want to be able to mouseover a div and hide the background image and display a new div over it (I have the div that I want to appear as an absolute so there is no issue), I could get the div to hide but cannot get to get it back whenmouseleve, here is the code I have
$('.div_to_hide').hover(function() {
var $this = $(this);
$this.stop().fadeTo('slow', 0.5, function(){
$('.div_to_appear').fadeIn('slow');
});
}, function(){
var $this = $(this);
$this.stop().fadeTo('slow', 1.0, function(){
$('.div_to_appear').fadeOut('fast');
});
});
Hope someone can help me with this situation. It keeps making me a loop going in and out constantly :(
Thanks apreciate your help as used to
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您显示的 DIV 可能位于隐藏的 DIV 之上,触发 mouseleave 事件来创建事件循环。尝试将悬停事件添加到父元素而不是您实际隐藏的 DIV。
The DIV you are showing is probably laying above the hiding DIV, triggering a mouseleave event that creates an event loop. Try adding the hover event to the parent element instead of the DIV you are actually hiding.