I am not the best at wording my questions, sorry. I am trying to make a sidenav which displays when you hover over a small strip on the side of the screen, then disappears on mouse out.
<!--the small bar on the side-->
<div id="sidebar"></div>
<!--the nav to display-->
<nav id="sidenav">
<ul>
<li>HOME</li>
<li>ABOUT</li>
</ul>
</nav>
Then I used some css to put them on the side and make them look pretty. Next, I added some JS:
<div id="sidebar" onmouseenter="show()">""</div>
<nav id="sidenav" onmouseout="hide()">""</nav>
<script>
function show() {
document.getElementById("sidebar").style.display = "none";
document.getElementById("sidenav").style.display = "block";
}
function hide() {
document.getElementById("sidebar").style.display = "block";
document.getElementById("sidenav").style.display = "none";
}
</script>
The scirpt works fine, just as I want it to. The only problem I am running into is that when I try to hover over the list items, the hide() function runs, as if it takes me entering the UL as a mouseout.
P.S. I am currently in the process of learning JS so please bare that in mind when making judgment calls.