开发者

jQuery animate relative position (on hover) bug,

Whenever the following code is run in Chrome and FF (not tested in other browsers), the "text" goes as such , as in the image. The script is supposed to lift the "text" 4px above on mouseover and return it back on mouseout

But instead when the mouse is brought in the motion as below, each time it lifts 4px above to its last position.

$(document).ready(function(){
    $('#n #c a').hover开发者_Go百科(function(){
        $('span',this).stop(true,true).animate({top:'-=4px'},200);
    },function(){
        $('span',this).stop(true,true).animate({top:'+=4px'},400);
    });
});

jQuery animate relative position (on hover) bug,

NOTE : In above image the text is just one, others are shown for understanding purpose. You have to be quick to catch the same effect.


I think you can just set the top to -4px on hover and 0px when the mouse exists

$(document).ready(function(){
    $('#n #c a').hover(function(){
        $('span',this).stop(true,true).animate({top:'-4px'},200);
    },function(){
        $('span',this).stop(true,true).animate({top:'0px'},400);
    });
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜