当我悬停一个元素然后将一个内部元素悬停时,我遇到了麻烦。我不知道它是否是我想要实现的最佳方式。这是我的代码:
我的标记:
<div class="wrapper">
<div class="animation">
<a href="#" class="linked"><img src="#"/></a>
<h1 class="title hidden"><a href="#">blabla</a></h1>
</div>
</div>
我的js:
$('.animation a img').hover(function(){
$(this).parent().next().stop().fadeTo("medium", 1);
$(this).stop().fadeTo("fast", 0);
}, function(){
$(this).parent().next().stop().fadeTo("medium", 0);
$(this).stop().fadeTo("fast", 1);
});
CSS:
#wrapper {margin: 0 auto; width: 960px;}
#hidden {display: none;}
h1 a {bottom: 0; float: left; font-size: 1.5em; left: 0; position: absolute; width: 460px;}
.linked {background: #666; float: left; height: 250px;}
当我将H1悬停时,闪烁开始。有没有办法禁用或修复它?
提前致谢!
答案 0 :(得分:0)
这就是你想要的http://jsfiddle.net/GWHrK/2/
$('.animation a img').hover(function(){
$(this).parent().next().stop().fadeTo("medium", 1);
$(this).stop().fadeTo("fast", .5);
});