2014-02-14 121 views
0

你好,我真的不知道爲什麼這不起作用,警報有效,但動畫沒有。用鼠標懸停()和的mouseenter(已經嘗試過),請一些提示:jquery動畫高度問題

<body> 
    <div id ="upBar"></div> 
    <div id ="middleBar"></div> 
    <div id="middleImg"></div> 
    <div id ="wrapper"> 
     <header> 
       <nav> 
        <a href="index.html"><img id="logo" src="imgs/logo.png"></a> 
        <ul> 
         <li id ="lang"><a href="#">PT</a>/<a href="#">EN</a></li> 
         <a href="#"><li>Notícias</li></a> 
         <a href="#"><li>Logistica</li></a> 
         <a href="#"><li>Serviços</li></a> 
         <a href="#"><li>Quem Somos</li></a> 
        </ul> 
       </nav> 
     </header> 

CSS

#upBar { 
    background-color: #FFF; 
    opacity: 0.9; 
    width: 100%; 
    height: 45px; 
    position: fixed; 
    z-index: 1; 
} 

jQuery的

$(document).ready(function(){ 
    alert('ready'); 
    $('#upBar').hover(function(){ 
     $(this).stop(true).animate(function(){ 
      height: '60px' 
     },300); 
    }) 
}) 

回答

1

.animate(),函數的第一個參數是性能這是一個對象CSS屬性和動畫將移向的值。

使用

$(document).ready(function(){ 
    alert('ready'); 
    $('#upBar').hover(function(){ 
     $(this).stop(true).animate({ //<- notice no 'function' 
      height: '60px' 
     },300); 
    }) 
})