开发者

hover in jQuery increment fontSize error

ok, I'm fooling around with jQuery and for the life of me can't find an elegant way to fix this error.

jQuery('a').hover(functi开发者_如何学编程on()
{
    jQuery(this).animate({fontSize : '+=5'});
}, function()
{
    jQuery(this).animate({fontSize : '-=5'});
});

The problem with that is that I build up an animation que. I thought i could solve it with stop() like this:

jQuery('a').hover(function()
{
    jQuery(this).stop().animate({fontSize : '+=5'});
}, function()
{
    jQuery(this).stop().animate({fontSize : '-=5'});
});

But if you mouse over it and unmouse over it you lose a full 5px even though it didn't yet add 5 yet. Is there a way to reset the pixel size something like .css(fontSize, "") or computedStyle or something like that?


you're almost there. you just need to use .stop(true,true).

crazy demo

Welcome to stackoverflow.com

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜