2012-08-27 171 views
0

我現在有一個像一個div覆蓋,我目前使用下面的代碼淡出的圖像顯示在下方的元素中的文本:淡出/淡入圖像在元素

$(".Content_Frame_Image").hover(
function() { 
$(this).stop().animate({"opacity": "0"}, "slow"); 
}, 
function() { 
$(this).stop().animate({"opacity": "1"}, "slow"); 
}); 

但是因爲我只是在使得它無形的我不能得到的鏈接下工作,你可以看到一個樣本在這裏http://playing.everythingcreative.co.uk

如果我使用淡出方法,然後它不會淡入懸停......

+0

您可能能夠使用CSS指針的事件這一點。 – j08691

+0

試過,但它只是忽略了淡出元素 –

回答

1

什麼有關:

$(".Content_Frame_Container") 
    .each(function(){ 
     $(this).find('.Content_Frame_Image'); 
    }) 
    .hover( 
     function(){ 
      $(this).find('.Content_Frame_Image').stop().fadeOut('slow'); 
     }, 
     function(){ 
      $(this).find('.Content_Frame_Image').stop().fadeIn('slow'); 
     } 
    ); 

用chrome開發工具測試它 - 應該很好地工作。

+0

_如果我使用淡出方法,那麼它不會淡入淡出...... _ – j08691

+0

聽起來真的很奇怪?!?! 應該工作! (可能需要交換的功能?* lookUp *) – TheHe

+0

啊... 1.他們理論上需要交換.. – TheHe

0

如果您需要使用不透明的,而不是淡出,你的動畫後的回調函數:

$(".Content_Frame_Image").hover(
function() { 
    $(this).stop().animate({"opacity": "0"}, "slow", function() { 
     //move the element off-screen 
     $(this).css({ 
      'position' : 'absolute', 
      'left' : '-9999px' 
     }); 
    }); 
}, 
function() { 
    //move it back first 
    $(this).css({ 
     'position' : 'absolute', 
     'left' : '0' 
    }); 
    $(this).stop().animate({"opacity": "1"}, "slow"); 
}); 
+0

另外,你可以改變它的z-index低於它所覆蓋的元素 – velocityhead

+0

謝謝你的快速回復......但我剛剛嘗試過,它導致文本消失,我更新了http://正在播放.everythingcreative.co.uk –

+0

如果我改變它在文本元素後面的z索引 –