简体   繁体   English

使用jQuery的mouseover mouseout上的链接的褪色

[英]Fading colour of links on mouseover mouseout with jQuery

Im trying to achieve a nice fade to color effect when you mouse over links in jQuery. 当您将鼠标悬停在jQuery中的链接上时,我正在尝试实现一种很好的淡入颜色效果。

So far I have: 到目前为止,我有:

$('a').hover(
function () { 
    $(this).animate({ color: '#fff' }, 1000 );
},
function () { 
    $(this).animate({ color: '#000' }, 1000 );
});

Which actually does work fine. 哪个实际上工作正常。 However, imagine if the links are navigation, being close to each other. 但是,请想象一下,如果链接是导航的,并且彼此靠近。 If you tried hovering from one link, to the one next to it and back several times. 如果您尝试从一个链接悬停,请转到该链接旁边的链接并返回几次。 The links go mental fading in and out, how would I stop an event being "queued" if there is a animation already happening? 链接进入和退出心理状态,如果已经发生动画,我如何阻止事件被“排队”?

Any advice appreciated! 任何建议表示赞赏!

You're looking for the stop function 您正在寻找stop功能

$('a').hover(
    function () { 
        $(this).stop().animate({ color: '#fff' }, 1000 );
    },
    function () { 
        $(this).stop().animate({ color: '#000' }, 1000 );
    }
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM