我使用 jQuery 1.4.3 和 jQuery UI 1.8.5 构建了一个垂直手风琴导航,以支持手风琴小部件的 hoverintent 版本。
它按预期工作,但是当用户导航到另一个页面时菜单会折叠。
有什么我忽略的吗?
的HTML
<nav class="span3">
<a href="index.html"><img src="img.png" width="250" /></a>
<ul class="wrap" id="mainNav">
<li>
<a href="javascript:void(0);" class="accordionButton">Lorem</a>
<ul class="accordionContent" style="display: none;">
<li>
<a href="javascript:void(0);">Ipsum</a>
</li>
<li class="">
<a href="javascript:void(0);">Dolor</a>
</li>
<li>
<a href="javascript:void(0);">Sit</a>
</li>
</ul>
</li>
<li>
<a href="javascript:void(0);" class="accordionButton accordionButton noChild">Amet</a>
</li>
<li>
<a href="javascript:void(0);" class="accordionButton accordionButton noChild">Consectetur</a>
</li>
<li>
<a href="javascript:void(0);" class="accordionButton accordionButton noChild">Adipiscing</a>
</li>
<li>
<a href="javascript:void(0);" class="accordionButton accordionButton noChild">Elit</a>
</li>
</ul>
</nav>
JavaScript
// verticle menu
function vertAccordHover() {"use strict";
$accButtons.mouseover(function() {
$(this).addClass('hover');
}).mouseout(function() {
$(this).removeClass('hover');
});
}
function vertAccord() {"use strict";
$("#mainNav").accordion({
event : "mouseover",
alwaysOpen : false,
autoHeight : false,
navigation : true,
collapsible : true
});
$('.noChild').unbind('mouseover');
$('#mainNav').accordion('activate', 0);
$('#mainNav').accordion( "option", "navigation", true );
vertAccordHover();
}