You can see a working demo of the following here.
オーバーホバリングするとき、それは良く振る舞うように私はこのような状況でmouseenter
[DOCS]とmouseleave
DOCSを好みます子供。
<div class="mask-layer">
<a class="top-link-cart" href="http://www.w3schools.com/">Test</a>
<div class="slidedown">div should close if user moves mouse away from test (but not to the gray area) or away from the gray area. The .mouseout function doesn't appear to work. </div>
</div>
は、私は、あなたのJavaScriptにを再構築:あなたが滑り落ちる灰色の領域にカーソルを合わせると、以下のようにそれはmouseleave
と考えられていないようにホバーは、リンクの親のdivの上にあるように、私はあなたのHTMLを再構築しましたホバーイベントの.mask-layer
を使用して、次のようにslideUp
[DOCS]とslideDown
[DOCS]でアニメーションを簡素化:
$('.slidedown').hide();
$('div.mask-layer').mouseenter(function() { // enter animation
$('.slidedown').slideDown(600);
}).mouseleave(function() {
setTimeout(function() {
$('.slidedown').slideUp(600);
}, 200);
});
こんにちは、ありがとうコード例です。私は、a.top-linkと.slideownを.mouseout関数のターゲットとして配置するロジックを見ることができます。しかし、これは、ユーザーがマウスの上にマウスを移動する機会がある前に、スライダをスライドバックアップにします。スリップダウンエリアにマウスを置いた場合に限り、スライドレールを開いたままにする方法はありますか? – user1448260
私の答えはタイムアウトを使ってうまくいくはずです。 – brendan