这是HTML代码
<div id="_navigation">
<ul>
<li>Destinations</li>
<li><a href="HtmlPage.html">Culture</a></li>
<li><a href="HtmlPage.html">Adventure</a></li>
<li><a href="HtmlPage.html">Hotels</a></li>
<li><a href="HtmlPage.html">Wild Life</a></li>
<li><a href="HtmlPage.html">History</a></li>
<li><a href="HtmlPage.html">About</a></li>
</ul>
<div id="_subNavigation">
<div id="_navigationFirst">
this is first subnavigation it must be showed when user clicks on Distinations
</div>
<div id="_navigationSecond">
this is second subnavigation it must be showed when user clicks on Culture
</div>
<div id="_navigationThird">
this is third subnavigation it must be showed when user clicks on Adventure
</div>
</div>
</div>
之后我在上面应用了一些 CSS,看起来这 忘记了 CSS 中的其他内容......在 ID 为 _subNavigation 的 CSS div 中设置为 display:none; 使用java脚本我希望当有人点击Destination时_navigationFirst(它是一个id)变得可见,当用户将鼠标移出导航区域时它会熄灭(变得不可见)..当用户点击它时我成功使它可见但是当用户将鼠标移出导航区域时它不会熄灭。这是我的 javascipt
当我点击目的地时,我得到了这样想要的图像
"use strict";
document.getElementById("_navigation").getElementsByTagName("ul")[0].getElementsByTagName("li")[0].onclick = function () {
console.log("got into block");
document.getElementById("_navigationFirst").style.display = "block";
}
document.getElementById("_navigation").onmouseleave = function () {
console.log("you left _navigation block");
document.getElementById("_navigationFirst").style.display = "none";
}
那么CodeGurus 我哪里错了?以及如何实现我想要的效果