这里是我可能(并希望)简单的问题:Jquery click and toggle Class question
我有一个图像列表与导航。当你将鼠标悬停在它们上面时,jquery用一个标题动画一个div并显示它。它会在mouseout消失。 (工作正常)
当你点击图像,标题div动画进一步,并完全覆盖图像(工作正常)。同时在nav中的另一张图片上悬停,caption div动画也很好(工作正常)。
问题:点击第二个导航图像时,第一个(点击)的动画应该消失。
这里的jQuery的:
var thumbslide = $('.boxgrid.captionfull').click(function() {
$(this).toggleClass('clicked').children('.cover').stop().animate({top: 0, height:"230px", opacity: 1}, 350);
});
$('.boxgrid.captionfull:not(.clicked)').live('mouseenter', function() {
$(this).children('.cover').stop().animate({top: 130}, 350);
}).live('mouseleave', function() {
$(this).children('.cover').stop().animate({top: 230}, 350);
})
,这里是到dev site
任何帮助是值得欢迎的,感谢的链接。
真棒。作品。但为什么Jamiecs代码(不包括动画部分)只有在再次悬停在最后一项上时才起作用?我的意思是......它确实删除了这个班,但是它不应该再返回到之前的状态?只是想知道.. – tobiasmay 2010-11-08 17:13:58
因为你的'mouseenter' /'mouseleave'代码设置了'top'的值。所以当你对它进行挖掘时,它仍然会进行动画制作,但不透明度将不会恢复。 – PetersenDidIt 2010-11-08 21:13:25