2014-01-09 35 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