2012-03-21 87 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/