工作這是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