如何使用jquery使此选项卡动画显示?

Ant*_*ony 3 jquery hover jquery-animate

我希望这个标签在悬停时有动画

之前:之前

悬停时:后

我如何用jquery来解决这个问题?

<div class="recruiterLink">
<a href="http://mydomain.com/recruiter/">
<span>Recruiting?</span>
<br>
Advertise a vacancy »
</a>
</div>
Run Code Online (Sandbox Code Playgroud)

谢谢!

Sim*_*n H 5

这可能是你正在寻找的东西:

$(document).ready(function() {

    $('#tab-to-animate').hover(function() {

        // this anonymous function is invoked when
        // the mouseover event of the tab is fired

        // you will need to adjust the second px value to
        // fit the dimensions of your image
        $(this).css('backgroundPosition', 'center 0px');

    }, function() {

        // this anonymous function is invoked when
        // the mouseout event of the tab is fired

        // you will need to adjust the second px value to
        // fit the dimensions of your image
        $(this).css('backgroundPosition', 'center -20px');

    });

});
Run Code Online (Sandbox Code Playgroud)

抱歉误读了这个代码应该做的问题,假设你最初使用position:relative css属性将它推下来.

$(document).ready(function() {

    $('.recruiterLink').hover(function() {

        $(this).css({
            'position' : 'relative',
            'top' : 0
        });

    }, function() {

        $(this).css({
            'position' : 'relative',
            'top' : 20
        });

    });

});
Run Code Online (Sandbox Code Playgroud)