鼠标悬停时字幕会闪烁
问题可以在这里看到: http://www.studioimbrue.com/beta
代码:
$(document).ready(function(){
$('div.caption').hide();
$('.captions ul li img').hover(function(){
$(this).siblings('div.caption').fadeIn('medium');
}, function(){
$(this).siblings('div.caption').fadeOut('medium');
});
});
不确定是什么导致了问题...一切似乎都设置正确。
problem can be seen here: http://www.studioimbrue.com/beta
The code:
$(document).ready(function(){
$('div.caption').hide();
$('.captions ul li img').hover(function(){
$(this).siblings('div.caption').fadeIn('medium');
}, function(){
$(this).siblings('div.caption').fadeOut('medium');
});
});
Not sure what's causing the problem... Everything seems to be set up correctly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是,当标题出现时,鼠标不再位于图像上 - 一个
mouseleave
事件被发送到图像,一个mouseenter
事件被发送到标题 div。前者触发淡出。您可以通过将图像和标题放入容器元素(例如)并在此容器上应用事件处理程序来解决此问题。那么无论标题是否显示,外部容器都不会收到
mouseleave
。编辑:这是一个工作示例:
HTML:
Javascript:
The problem is that when the caption appears, your mouse is no longer on the image - a
mouseleave
event is sent to the image and amouseenter
to the caption div. The former triggers the fadeout. You can solve that by placing both the image and the caption into a container element (e.g. a<div>
) and applying the event handler on this container. Then no matter whether the caption is showing or not, the outer container will not receive amouseleave
.EDIT: Here's a working example:
HTML:
Javascript: