我有一个网格的div看起来像一张桌子。
#wrapper
> div.container > h2 (hidden)
> div.container > h2 (hidden)
> div.container > h2 (hidden)
</>我想动画的背景颜色的悬浮div和显示h2在其中。
我的代码看起来是这样的。
$('.container').hover(function() {
$('.container>h2').stop().fadeOut(200);
$(this).stop().animate({ backgroundColor: '#3e95ff' }, 300);
},function() {
$('.container>h2').stop().fadeIn(200);
$(this).stop().animate({ backgroundColor: 'white' }, 300);
});问题是当我悬停一个div时,所有的H2都会显示出来。如何仅选择悬浮div的h2?
发布于 2014-03-30 07:47:32
试着改变这个
$('.container>h2').stop().fadeIn(200);使用
$(this).find('h2').stop().fadeIn(200);https://stackoverflow.com/questions/22741553
复制相似问题