マウスが画像の上にあるとき、スパンコンテンツは2秒後に下にスライドします。また、カーソルを画像の外に移動すると、2秒後にスパンコンテンツが上にスライドします。これは問題なく機能します。
誰かがそのスパン上にマウスを移動した場合にもスパンを表示したいのですが、そこから問題が始まります...
私が十分に明確であったかどうかはわかりませんが、コードは言葉以上のものを教えてくれると思います:)
リンク: 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);
}
});
});
前もって感謝します!