我有一個div裏面有一個嵌套的元素,它顯示了當鼠標懸停在div上時。這工作。爲什麼我的mouseout fadeOut工作,但然後再次淡入?
在mouseout上,嵌套元素應該隱藏起來,然後它會立即淡入,就好像我剛剛在初始div上執行了鼠標懸停一樣。
我製作了a jsfiddle replicating the issue over here。
的HTML是:
<div class="add_bag_large_wrap">
<div class="add_bag_large_droid" style="margin: 90px auto;">
I am a button.
<div class="add_includes">
<p>Show on hover, hide on mouseout</p>
</div>
</div>
的JS:
$('.add_bag_large_droid').live('hover',function(){
$(this).children('.add_includes').fadeIn();
}).mouseout(function(){
$('.add_includes').fadeOut();
});
的CSS:
.add_bag_large_wrap {
position: relative;
width: 390px;
height: 96px;
margin: 36px auto;
}
.add_bag_large_droid {
background: #ccc;
width: 390px;
height: 96px;
cursor: pointer;
background-size: 390px 192px;
position: static;
}
.add_includes {
background: #000; padding: 18px; color: #fff; position: absolute;
bottom: 110px; left: 50%; margin-left: -148px;
display: none;
text-align: left;
}
.add_includes p {
font-size: 11px; color: #fff; margin: 0;
}
是什麼原因造成這種現象?
但是,我們使用'live'?它可以動態添加元素。 – Samich 2012-08-17 13:36:14
更新。稍等片刻。 – davidbuzatto 2012-08-17 13:37:34
已更新。看一看。 – davidbuzatto 2012-08-17 13:40:16