マウスが画像上にあるとき、2秒後にスパンコンテンツが下にスライドします。それはうまくいく。2秒後にマウスの上/外にjQueryスライドアップ/アウトコンテンツ - バグ
私は誰かがあまりにもそのスパンの上にマウスを移動した場合に表示されるスパンにしたい、と私の問題が始まる...
私は十分に明らかになった場合、私は知らないが、私はコードがあなたよりも多くを教えてくれますだと思います言葉:)
リンク:http://jsfiddle.net/zDd5T/3/
HTML:
<img id="image" src="button_green.png" />
<span id="content">
<a href="http://www.google.com">Link</a>
Some content here
</span>
CSS:
#image{
left:0px;
position:absolute;
z-index: 10;
}
#content{
top:48px;
left:0px;
position:absolute;
height: 100px;
border: 1px solid #f00;
display: block;
z-index: 0;
width: 100px;
}
のJavaScript:事前に
$(document).ready(function() {
$('#content').hide();
var over_img = false;
var over_span = false;
$('#image').live('mouseover', function() {
over_img = true;
setTimeout(function() {
$('#content').show('slide', {
direction: 'up'
}, 1000);
}, 2000);
});
$('#content').live('mouseover', function() {
over_span = true;
setTimeout(function() {
$('#content').show('slide', {
direction: 'up'
}, 1000);
}, 2000);
});
$('#image').live('mouseout', function() {
over_img = false;
if (!over_img && !over_span) {
setTimeout(function() {
$('#content').hide("slide", {
direction: "up"
}, 1000);
}, 2000);
}
});
$('#content').live('mouseout', function() {
over_span = false;
if (!over_img && !over_span) {
setTimeout(function() {
$('#content').hide("slide", {
direction: "up"
}, 1000);
}, 2000);
}
});
});
ありがとう!
このコードは単語以上を教えてくれます:) ありがとうございます! – luka
@luka - 答えが実際にあなたの問題を解決するなら、それを受け入れるべきです。 – adeneo
また、mouseoutハンドラで 'clearTimeout(T1)'を実行すると、潜在的なslideDownを排除するのに役立ちます。特に、ユーザがマウスオーバー/マウスオーバーを素早く行う場合に便利です。 http://jsfiddle.net/zDd5T/10/ –