2013-02-13 82 views
0

我正在試圖做一個JavaScript函數來表示callout div和notch div是隱藏的,但是當鼠標懸停在contact_details_email上時會淡出callout和notch,然後在mouse_outtack_details_email中淡出callout和notch。在鼠標上顯示div對象?

我是JavaScript新手,有人能告訴我我需要做什麼嗎?

<script> 
    $(".callout").hide(); 
    $(".notch").hide(); 
     $('.contact_details_email').onMouseOver(function(){ 

       $('.callout').fadeIn(500); 
       $('.notch').fadeIn(500); 


     }); 
    </script> 
+1

你能分享你的html嗎? – Tucker 2013-02-13 06:32:15

+0

既然你使用的是類,而不是ID,我猜你想淡化特定於父div(.contact_details_email)的.callout和.notch div。是這樣嗎? – 2013-02-13 06:34:50

+0

是的,這是正確的 – 2013-02-13 06:39:13

回答

0

爲jQuery的鼠標懸停事件的一般格式如下(按了出色的文件,你可以在http://api.jquery.com/hover/

$(selector).hover(function(){ 
    //mouseover handler 
}, function(){ 
    //mouseout handler 
}) 

找到假設.callout和.notch是.contact_details_email的後代......

$('.contact_details_email').hover(function(){ 
    //mouseover handler 
    $(this).find('.callout').fadeIn(500); 
    $(this).find('.notch').fadeIn(500); 
}, function(){ 
    //mouseout handler 
    $(this).find('.callout').fadeOut(500); 
    $(this).find('.notch').fadeOut(500); 
}); 
相關問題