我无法打开' “键盘”键盘上的下拉菜单'键。 '打开的显示:屏幕没有启动..只能通过主要'顶部'菜单项,没有子菜单li项。请帮忙。 HTML,Jquery和' open'对于CSS是在下面。
<div class="top-nav">
<div class="menu-primary-navigation-container">
<ul id="menu-primary-navigation" class="menu">
<li id="menu-item-1833" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-home current-menu-item page_item page-item-5 current_page_item menu-item-1833">
<a href="http://lavarockrealty.com/">Home</a>
</li>
<li id="menu-item-1835" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1835"><a href="?page_id=6&quicksearch=true&officeid=1159">Our Listings</a></li>
<li id="menu-item-28" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-28"><a href="http://lavarockrealty.com/island-listings/">Island Listings</a></li>
<li id="menu-item-2059" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-2059">
<a>Rentals</a>
<ul class="sub-menu">
<li id="menu-item-739" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-739"><a href="http://lavarockrealty.com/home/management-team/">Management Team</a></li>
<li id="menu-item-27" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-27"><a href="http://lavarockrealty.com/long-term-rentals/">Long Term Rentals</a></li>
<li id="menu-item-1433" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1433"><a href="http://lavarockrealty.com/vacation-rentals/">Vacation Rentals</a></li>
<li id="menu-item-1559" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1559"><a href="http://lavarockrealty.com/property-management/">Property Management</a></li>
</ul>
</li>
<li id="menu-item-2086" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-2086">
<a>About Us</a>
<ul class="sub-menu">
<li id="menu-item-22" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22"><a href="http://lavarockrealty.com/our-agents/">Meet Our Agents</a></li>
<li id="menu-item-21" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-21"><a href="http://lavarockrealty.com/our-testimonials/">Testimonials</a></li>
<li id="menu-item-23" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-23"><a href="http://lavarockrealty.com/mission-and-vision/">Mission and Vision</a></li>
<li id="menu-item-2105" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2105"><a href="http://lavarockrealty.com/community-service/">Community Service</a></li>
</ul>
</li>
<li id="menu-item-2087" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-2087">
<a>Island Living</a>
<ul class="sub-menu">
<li id="menu-item-26" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-26"><a href="http://lavarockrealty.com/island-living/">Island Information</a></li>
<li id="menu-item-25" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-25"><a href="http://lavarockrealty.com/big-island-maps/">Hawai’i Island Maps</a></li>
<li id="menu-item-24" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-24"><a href="http://lavarockrealty.com/island-links/">Island Links</a></li>
<li id="menu-item-1932" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1932"><a href="http://lavarockrealty.com/communities/">Communities</a></li>
</ul>
</li>
<li id="menu-item-1994" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-1994">
<a>Resources</a>
<ul class="sub-menu">
<li id="menu-item-2721" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2721"><a href="http://lavarockrealty.com/blog-posts/">Blog Posts</a></li>
<li id="menu-item-1931" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1931"><a href="http://lavarockrealty.com/preferred-vendors/">Preferred Vendors</a></li>
</ul>
</li>
<li id="menu-item-1729" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-ancestor current-menu-parent menu-item-has-children menu-item-1729">
<a>Translate</a>
<ul class="sub-menu">
<li id="menu-item-1824" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-1824"><a href="http://lavarockrealty.com">English</a></li>
<li id="menu-item-1730" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1730"><a href="http://translate.google.com/translate?u=http%3A//lavarockrealty.com/&sl=en&tl=zh-CN">Chinese (simplified)</a></li>
<li id="menu-item-1936" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1936"><a href="http://translate.google.com/translate?hl=&sl=en&tl=zh-TW&u=http%3A%2F%2Flavarockrealty.com%2F&sandbox=1">Chinese (traditional)</a></li>
<li id="menu-item-1731" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1731"><a href="http://translate.google.com/translate?hl=&sl=en&tl=ja&u=http%3A%2F%2Flavarockrealty.com%2F&sandbox=1">Japanese</a></li>
</ul>
</li>
</ul>
</div>
</div>
使用Javascript:
$('a:not([href]').each(function() {
$('a:not([href]').attr('tabindex', '0');
});
$('ul#menu-primary-navigation > li').keydown(function(e) {
if(e.keyCode == 9){
var topMenu = $(this).next('li');
var subMenu = $(this).next('li > ul.sub-menu');
topMenu.addClass('ada-outline');
subMenu.addClass('open');
console.log('subMenu', subMenu);
}
});
.open{display: block;}