mouseover および mouseout 機能に問題があります。リンクにマウスオーバーすると hidden が表示され<div>
、div からマウスアウトすると div が非表示になります。問題は、マウスをリンクの上に置いた場合、マウスを div の上にない別の場所に移動すると、div が消えないことです。
リンクのマウスアウト イベントを使用して div の可視性を設定すると、div にカーソルを合わせることができなくなります。
ここに私のHTMLがあります:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
Untitled Document
</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js">
</script>
<script type="text/javascript">
$(document).ready(function() {
$("#show_div").mouseover(function() {
$("#hello").css('visibility', 'visible');
});
$("#hello").mouseover(function() {
$("#hello").css('visibility', 'visible');
});
$("#hello").mouseout(function() {
$("#hello").css('visibility', 'hidden');
});
});
</script>
</head>
<body>
<br/>
<br/>
<br/>
<br/>
<a id="show_div" href="#">Link text</a>
<div id="hello" style="visibility:hidden;">
<ul>
<li>
Coffee
</li>
<li>
Tea
</li>
<li>
Milk
</li>
</ul>
</div>
<br/>
<br/>
</body>
</html>