Javascript jQuery动画相对位置(悬停时)错误,

Javascript jQuery动画相对位置(悬停时)错误,,javascript,jquery,hover,Javascript,Jquery,Hover,每当以下代码在Chrome和FF中运行时(未在其他浏览器中测试),“text”就会像图像中那样运行。 脚本应该在mouseover上提起上面的“text”4px,然后在mouseout 但是,当鼠标进入如下运动时,每次它将4px提升到其最后位置 $(document).ready(function(){ $('#n #c a').hover(function(){ $('span',this).stop(true,true).animate({top:'-=4px'},2

每当以下代码在Chrome和FF中运行时(未在其他浏览器中测试),
“text”
就会像图像中那样运行。 脚本应该在
mouseover
上提起上面的
“text”
4px,然后在
mouseout

但是,当鼠标进入如下运动时,每次它将4px提升到其最后位置

$(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:'+=4px'},400);
    });
});

注:在上图中,文本仅为一个,其他文本显示用于理解目的。
你必须快速捕捉到同样的效果。

我认为你可以在悬停时将顶部设置为-4px,在鼠标存在时设置为0px

$(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);
    });
});

谢谢,:-)现在好多了!,虽然它仍然会抬起,但至少它会回到原来的位置。文本是否仍有可能被限制在特定的区域,因此,如果试图穿过它,它会反弹回原来的位置?您也可以使用类似以下内容的css3方式:
#c a{-webkit转换:所有0.2s的输入输出;-moz转换:所有0.2s的输入输出;-o-transition:所有0.2s的输入输出;-webkit转换:所有0.2s的输入输出;转换:所有0.2s的输入输出;}cA:悬停{margin top:-4px;
@Val快速尝试,就像链接周围的旋转运动一样…哦,好的,我明白了lol:)btw“-=4px”我认为是将某物增加4px,就像使用
I++;
inc增加1一样,在本例中,它的意思是'top+4px',依此类推