2014-02-14 123 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); 
    }) 
})