jQuery悬停问题

时间:2011-05-23 09:48:49

标签: jquery css

在我的网站上,我有一个带有图像网格的页面。我想要的是一张图像在悬停时向下滑动,因此它会变长但不会移动。如果这是有道理的。

我有以下代码,它不起作用/做任何事情:

<script type="text/javascript">
    $(".piece").hover(function () {
        $(this).slideDown(1000, function () {
            $(this).css("height", "250px");
        });
    });
</script>

希望这个问题有道理。非常感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

我想你想使用animate函数:

$(".piece").hover(
    function () {
        $(this).animate({
            height: '250'
        }, 1000);
    }, 
    function() {
        $(this).animate({
            height: '100'
        }, 1000);
    }
);

JSFiddle Example

相关问题