2014-01-09 34 views
0

http://jsfiddle.net/rR6gC/jQuery的 - 鼠標懸停()/淡入()不工作

我想每當有人在每個條推自己的鼠標,以顯示巴內部信息,但它不工作。我能夠使它從純CSS做出反應,但是當嘗試使用jQuery函數時,沒有任何工作。

的JavaScript/jQuery的

$('.score').mouseover(function() { 
    $(this).fadeIn('slow'); 
}); 
$('.score').mouseeleave(function() { 
    $(this).fadeOut('slow'); 
}); 

CSS

.score{ 
color:white; 
font-size:2em; 
width:100%; 
text-align:center; 
display:inline-block; 
position:relative; 
} 
+0

在代碼上有一個錯誤:Object [object Object]沒有方法'mouseeleave' – AFetter

+0

你有一個錯字:mouseleave(',not'mouseeleave('(注意兩個'ee')。 – acdcjunior

+0

當您將鼠標懸停在欄上時,您想顯示哪個div? –

回答

3

從我能理解你想隱藏5並顯示它當鼠標懸停在酒吧

  1. 有一個錯字
  2. 你需要寫了吧包裝元素的mouseenter和鼠標離開事件,然後顯示/隱藏內,當鼠標進入它的得分元素/葉

嘗試

$('.scoreWrap2 .score').hide() 
$('.scoreWrap2').mouseover(function() { 
    $(this).find('.score').stop(true, true).fadeIn('slow'); 
}); 
$('.scoreWrap2').mouseleave(function() { 
    $(this).find('.score').stop(true, true).fadeOut('slow'); 
}); 

演示:Fiddle

+0

非常感謝!完美地工作 – bob