Foucusout正在研究Chrome,但不是FF或IE。我已经建立了一个基本的下拉菜单,可以在点击时打开,然后关闭焦点。当我点击第二层的链接时,UL'下拉菜单已关闭,但未转到请求的页面。 *第二级导航将在第一级导航栏悬停时打开,请参阅下面的代码。
感谢
JS
// Main Drop down Navigation
resources.on('click', 'a.dropdown', function (e) {
e.preventDefault();
var menu;
select = $(this);
menu = select.closest('ul');
menu.focus().addClass('open');
}).on('focusout', 'ul.menu', function (e) {
select = $(this);
select.removeClass('open');
});
HTML
<div class="custom-dropdown">
<ul class="menu level0" tabindex="-1">
<li><a class="dropdown" href="#">Please select a database</a>
<ul class="level1" tabindex="-1">
<li><span>Cancer</span>
<ul class="level2" tabindex="-1">
<li><a class="noAccess" href="http://www.google.com">Cancer e-atlas</a></li>
<li><a href="http://www.google.com">Cancer Mortality Profile</a></li>
<li><a href="http://www.google.com">Cancer Patient Experience</a></li>
<li><a href="http://www.google.com">Cervical screening cancer e-Atlas</a></li>
<li><a href="http://www.google.com">GP Pratice Profiles</a></li>
<li><a href="#">Gynaecological Cancer Hub</a></li>
<li><a href="#">Gynaecological Cancer Profiles</a></li>
<li><a href="#">Head and Neck Cancer e-Atlas</a></li>
<li><a href="#">National Radiotherapy Profiles</a></li>
<li><a href="#">PCT Profiles</a></li>
<li><a href="#">Prevalence e-Atlas</a></li>
<li><a href="#">Profile of head and neck cancers in England</a></li>
<li><a href="#">Service profiles</a></li>
<li><a href="#">Skin Cancer Profiles</a></li>
<li><a href="#">Systemic Anti-Cancer Therapy (chemotherapy)</a></li>
<li><a href="#">Thirty-day postoperative mortality after colorectal</a></li>
<li><a href="#">Understanding Cancer e-Learning</a></li>
<li><a class="locked" href="#">Urological Cancer Hub</a></li>
<li><a class="locked" href="#">Urological Cancer Profiles</a></li>
</ul>
</li>
<li><span>Comparison pratice and performance</span></li>
<li><span>Drugs and Alcohol</span></li>
<li><span>Health inequalities</span></li>
<li><span>Health needs</span></li>
<li><span>Health Profiles</span></li>
<li><span>Hospital episodes and admissions</span></li>
<li><span>Infectious and communicable disease</span></li>
<li><span>Injuries and violence</span></li>
<li><span>Learning Disabilities</span></li>
<li><span>Lifestyle, diet and exercise</span></li>
<li><span>Long term conditions</span></li>
<li><span>Mental health</span></li>
<li><span>Other</span></li>
<li><span>Screening</span></li>
<li><span>Sexual health</span></li>
<li><span>Smoking</span></li>
<li><span>Social care, adults and older people</span></li>
</ul>
</li>
</ul>
</div>