2012-11-25 36 views
-3

你好计算器jQuery不会工作?动画功能

进入jQuery的一些教程,因为我想开始2d聊天。

我有一个代码,应该使一些图像在50%的不透明度,100%时,一个漫画家盘旋的图像,但它不会工作?图像是50%,但不会更改为100%。

我的代码:

$(function(){ 

    $('#container img').animate({ 
     "opacity" : .50 
    }); 

    $('#container img').hover(function() { 
     $(this).animate({ "opactiy": 1 }); 
     console.log("Den er nu 100% klar"); 
    }); 

}); 
+3

来吧.... ** ** opactiy还 – Prinzhorn

+0

你需要第二个悬停功能,以减少再次不透明,如果这是你的效果”重新瞄准... – ahren

回答

0

中只要改变opactiyopacity你的第二个.animate()

$(function(){ 

    $('#container img').animate({ 
     "opacity" : .50 
    }); 

    $('#container img').hover(function() { 
     $(this).animate({ "opacity": 1 }); // <-- Right here 
     console.log("Den er nu 100% klar"); 
    }); 

});​ 

jsFiddle

1

你已经在你的悬停声明中有一个错字:

$(this).animate({ "opactiy": 1 }); 

应该是:

$(this).animate({ "opacity": 1 }); 
0
$(function(){ 

    $('#container img').animate({ 
     opacity : '1' 
    }); 

    $('#container img').hover(function() { 
     $(this).animate({ opacity:'0.5' }); 

    },function(){ 
      $(this).animate({ opacity:'1' }); 

    }); 

});​ 

JSFIDDLE