当鼠标悬停在此菜单中的子菜单上时,如何使 :hover 状态保持在顶层?这可能很简单,但我似乎无法让它发挥作用。我试过做 mouseEnter 但我很可能做的不正确,因为我对 jQuery 知之甚少。提前致谢!
<!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>New Menu</title>
<link rel="stylesheet" type="text/css" href="droplinetabs.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="droplinemenu.js" type="text/javascript"></script>
<script type="text/javascript">
//build menu with DIV ID="myslidemenu" on page:
droplinemenu.buildmenu("droplinetabs1")
</script>
</head>
<body>
<div id="droplinetabs1" class="droplinetabs">
<ul id="base">
<li><a href="#">Stuff to Do</a>
<ul>
<li class="base"><a href="#">Activities 1.1</a>
<ul>
<li><a href="#">Cricket</a></li>
<li><a href="#">Rugby</a></li>
<li><a href="#">Soccer</a></li>
<li><a href="#"> Football</a></li>
</ul>
</li>
<li><a href="#">Activities 1.2</a>
<ul>
<li><a href="#">Eating</a></li>
<li><a href="#">Cooking</a></li>
<li><a href="#">Baking</a></li>
</ul>
</li>
<li><a href="#">Activities 1.3</a>
<ul>
<li><a href="#">Music</a></li>
<li><a href="#">Chess</a></li>
<li><a href="#">Reading</a></li>
<li><a href="#">Scribbling</a></li>
</ul>
</li>
</ul>
</li>
<li class="base"><a href="#">More Stuff to Do</a>
<ul>
<li><a href="#">Activities 2.1</a>
<ul>
<li><a href="#">Cricket</a></li>
<li><a href="#">Rugby</a></li>
<li><a href="#">Soccer</a></li>
<li><a href="#"> Football</a></li>
</ul>
</li>
<li><a href="#">Activities 2.2</a>
<ul>
<li><a href="#">Eating</a></li>
<li><a href="#">Cooking</a></li>
<li><a href="#">Baking</a></li>
</ul>
</li>
<li><a href="#">Activities 2.3</a>
<ul>
<li><a href="#">Music</a></li>
<li><a href="#">Chess</a></li>
<li><a href="#">Reading</a></li>
<li><a href="#">Scribbling</a></li>
</ul>
</li>
</ul>
</li>
<li class="base"><a href="#">Even More</a>
<ul>
<li><a href="#">Activities 3.1</a>
<ul>
<li><a href="#">Cricket</a></li>
<li><a href="#">Rugby</a></li>
<li><a href="#">Soccer</a></li>
<li><a href="#">Football</a></li>
</ul>
</li>
<li><a href="#">Activities 3.2</a>
<ul>
<li><a href="#">Eating</a></li>
<li><a href="#">Cooking</a></li>
<li><a href="#">Baking</a></li>
</ul>
</li>
<li><a href="#">Activities 3.3</a>
<ul>
<li><a href="#">Music</a></li>
<li><a href="#">Chess</a></li>
<li><a href="#">Reading</a></li>
<li><a href="#">Scribbling</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</body>
</html>
和
var droplinemenu={
arrowimage: {classname: 'downarrowclass', src: 'down.gif', leftpadding: 5}, //customize down arrow image
animateduration: {over: 1, out: 1}, //duration of slide in/ out animation, in milliseconds
buildmenu:function(menuid){
jQuery(document).ready(function($){
var $mainmenu=$("#"+menuid+">ul")
var $headers=$mainmenu.find("ul").parent()
$headers.each(function(i){
var $curobj=$(this)
var $subul=$(this).find('ul:eq(0)')
this._dimensions={h:$curobj.find('a:eq(0)').outerHeight()}
this.istopheader=$curobj.parents("ul").length==1? true : false
if (!this.istopheader)
$subul.css({left:0, top:this._dimensions.h})
var $innerheader=$curobj.children('a').eq(0)
$innerheader=($innerheader.children().eq(0).is('span'))? $innerheader.children().eq(0) : $innerheader //if header contains inner SPAN, use that
$curobj.hover(
function(e){
var $targetul=$(this).children("ul:eq(0)")
if ($targetul.queue().length<=1) //if 1 or less queued animations
if (this.istopheader)
$targetul.css({left: $mainmenu.position().left, top: $mainmenu.position().top+this._dimensions.h})
if (document.all && !window.XMLHttpRequest) //detect IE6 or less, fix issue with overflow
$mainmenu.find('ul').css({overflow: (this.istopheader)? 'hidden' : 'visible'})
$targetul.dequeue().slideDown(droplinemenu.animateduration.over)
},
function(e){
var $targetul=$(this).children("ul:eq(0)")
$targetul.dequeue().slideUp(droplinemenu.animateduration.out)
}
) //end hover
}) //end $headers.each()
$mainmenu.find("ul").css({display:'none', visibility:'visible', width:$mainmenu.width()})
}) //end document.ready
}
}