2012-11-25 49 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