2012-01-29 48 views
0

我有一个侧边栏到我的网页右侧的博客的类别列表。如何停止类的.curent菜单项上的jQuery效果?

我已经设置了一个jQuery的效果,这样,当你将鼠标悬停在一个类别名称它5px的填充向左动画。

一切运作良好,但如果你点击某个类别,我希望它给你带来与同一类别栏列表分类页面,但与目前的类别有一类.current的。

我想目前的类别已经有5px的填充到左侧,当鼠标悬停在没有任何效果。

基本上只是为了让它从其他类别列表中脱颖而出。

这里是jQuery的我有个大气压:

// blog categories animation 
$(function() { 
    $('#blog-categories ul li a').hover(
    function(){ $(this).find('img').animate({paddingLeft: '+=5'}, 100); }, 
    function(){ $(this).find('img').animate({paddingLeft: '-=5'}, 100); } 
    ); 
}); 

如果有人知道有5px的一个很好的方式加入填充已存在于当前类别项目。当鼠标悬停

即“#博客类别UL李a.current”

,并没有进一步的动画,这将是伟大的!

我希望我已经解释过自己确定这里:)


这里有什么想对.current类项目我的截图:

enter image description here

回答

1

尝试使用.not()方法

$(function() { 
    $('#blog-categories ul li a').hover(
    function(){ $(this).not('.current').find('img').animate({paddingLeft: '+=5'}, 100); }, 
    function(){ $(this).not('.current').find('img').animate({paddingLeft: '-=5'}, 100); } 
    ); 
}); 

要有5p x填充目前,为什么不简单地将它添加到.current类?

+0

干杯我就现在试试这个,让你知道我是如何得到:) – ade123 2012-01-29 16:42:32

+0

工作一种享受!感谢您的快速回复:) – ade123 2012-01-29 16:44:51

+0

没问题。我很高兴它为你解决。 – shaunsantacruz 2012-01-29 16:48:04