工作这是HTML我有:jQuery的鼠标悬停不如预期
<div id="social">
<a href="#" class="twitter"><span class="text">Twitter</span></a>
</div>
我打算做的是最初隐藏span.text,当我将鼠标悬停在图像中的div的背景。这是我的CSS
#social a {
display:inline-block;
overflow:hidden;
padding:4px 0 0 28px;
/* left padding is for the bg image to be visible*/
}
#social a span {
display:none;
}
#social .twitter {
background:url(../images/social/twitter.png) no-repeat left top;
}
#social .twitter:hover {
background:url(../images/social/twitter_hover.png) no-repeat left top;
}
,这是我的js:
$("#social a.twitter").mouseover(function(){
$("span",this).show("slow");
}).mouseout(function(){
$("span",this).hide("slow");
});
但发生的事情是,当我将鼠标悬停在它不断显示和隐藏的文本图像..我要去哪里错了?
使用.hover而不是.mouseover事件。检查此链接http://stackoverflow.com/questions/1116361/jquery-hover-mouse-out –
@BishnuPaudel在这里使用'mouseover'和'mouseout'没有任何错误。 – iambriansreed