Jquery悬停功能未按预期工作
我想让用户能够查看我开发的网站的完整屏幕截图,然后当他们将鼠标悬停在该网站上时,另一个 div 会淡入其中并包含一些元信息。
这是一个测试链接 - http://www.deanelliott.me/misc/test -port/index.html
正如您所看到的,如果您将鼠标悬停在幻灯片上,则会出现一个覆盖层,这很好,但是当您将鼠标悬停在幻灯片上并且下一张幻灯片开始播放时,覆盖层会在不应该可见的情况下可见是。
如果有人对问题是什么有任何想法那就太好了!
谢谢
编辑:这是相关代码
$(function(){
$('#slideshow').hover(
function(){
$('.slideimage').fadeOut(100, function(){
$('.slideoverlay').fadeIn(100);
});
},
function(){
$('.slideoverlay').fadeOut(100, function(){
$('.slideimage').fadeIn(100);
});
}
);
});
.slideoverlay 通过 CSS 设置为 display:none
I want to be enable users to view a full screenshot of a website I have developed and then when they hover over it another div fades in with some meta information.
Here is a test link - http://www.deanelliott.me/misc/test-port/index.html
As you can see, if you hover over the slideshow an overlay appears which is fine, but when you hover off it and the next slide comes into play the overlay is visible when it shouldn't be.
If anyone has any ideas on what the problem is that would be great!
Thanks
Edit: Here is the relevant code
$(function(){
$('#slideshow').hover(
function(){
$('.slideimage').fadeOut(100, function(){
$('.slideoverlay').fadeIn(100);
});
},
function(){
$('.slideoverlay').fadeOut(100, function(){
$('.slideimage').fadeIn(100);
});
}
);
});
.slideoverlay is set to display:none via CSS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于某种原因,您的
fadeIn()
被应用于所有幻灯片叠加,但fadeOut()
仅应用于当前可见的幻灯片。我会尝试使fadeIn()
和fadeOut
仅影响您悬停在其上的实际内容。像这样的事情:可能可以使用一些优化,但我认为这应该可行。不过还没有测试过,祝你好运。
尝试用此方法消除白色闪光。基本上,我们的想法是,如果您只是将覆盖层覆盖在
$('.slideimage')
上,则无需隐藏它。您所需要做的就是隐藏和显示幻灯片。For some reason your
fadeIn()
is getting applied to all of the slideoverlays but thefadeOut()
only gets applied to the currently visible one. I would try to make it so that thefadeIn()
andfadeOut
only effect the actual one you are hovering over. Something like this:Could probably use some optimization, but I'm thinking this should work. Haven't tested though, so good luck.
Try this to get rid of the white flash. Basically, the thought is you don't need to hide the
$('.slideimage')
if you're just overlaying the overlay over it. All you need to do is hide and show the slideoverlay.