0
我試圖尋找類似的問題,用我的情況的反應,但無論是我做錯了(可能的...)或它不正是我需要的?jquery - 在mouseenter和mouseleave上切換不相關的div?
本質上,我試圖在#b-hover-nav上懸停時切換.block-5。不過,我想.block-5保持開放,使用戶可以讀取/與它的聯繫互動......這同樣適用於例如其他鏈接...
我已經張貼在的jsfiddle (http://jsfiddle.net/9fcFv/),但我還包括它下面:
#content {
width: 400px;
height: 400px;
}
span.button-hover-nav {
display: block;
clear: both;
width: 200px;
margin-bottom: 20px;
}
.left {
width: 200px;
float: left;
}
.block-5 {
display: none;
width: 200px;
float: right;
}
.block-5 a {
color: blue;
}
.block-6 {
display: none;
width: 200px;
float: right;
}
.block-6 a {
color: green;
}
<div class="body">
<span class="button-hover-nav" id="b-hover-nav">Hover Me</span>
</div>
<div class="block-5">
<h1>Please stay open unless I leave...</h1>
<a link="#">Click Me</a>
</div>
//Totally does not work:
// Bind the mouse over /out to the first DIV.
$('#b-hover-nav').live('mouseenter', function() {
$('.block-5').show();
}).live('mouseleave', function() {
t = setTimeOut(function() {
$('.block-5').hide();
}, 100);
});
$('.block-5').live('mouseenter', function() {
if(t) {
clearTimeout(t);
t=null;
}
});