2012-03-21 66 views
2

我试图在悬停时设置高度属性的动画,但我无法让它工作。 悬停时,我正在进入悬停功能,但它只是没有动画的高度。jquery动画,无法启动它

if (!Modernizr.csstransitions) { // Test if CSS transitions are supported 
if ($('#belt figure').length) { 
    $('#belt figure figcaption').hover(function() { 
     $(this).animate({ height: '7em;' }, { queue: false, duration: 500 }); 
    }, function() { 
     $(this).animate({ height: '3.8em;' }, { queue: false, duration: 500 }); 
    }); 
} 

}

+5

也许它的','在你的价值符号? – DoubleYo 2012-03-21 09:18:12

回答

1

你试过

$('#belt figure figcaption').hover(function() { 
    $(this).animate({ height: '7em' }, { queue: false, duration: 500 }); 
}, function() { 
    $(this).animate({ height: '3.8em' }, { queue: false, duration: 500 }); 
}); 

withouth的的;

+0

我认为这是问题,thx :) – nuffsaid 2012-03-21 09:38:23

2

这是我的例子

<div id="block" style='border:1px solid green;height:50px;width:100px;background-color:#bca;'>Hello!</div> 

HTML代码,这个jQuery的动画DIV高度:

$("#block").hover(function(){ 
    $(this).animate({ 
    height: "100px"  

    }, 500); 

},function(){ 
    $(this).animate({height: "50px" 
    }, 500); 
}); 

你也可以看到这个例子以下链接http://jsfiddle.net/jzRPa/29/