I have a JavaScript function called "display()". I want to hide my navigation menu on click, but it is not working properly - it just blinks.
I am looking for a solution that uses only JavaScript and does not involve querySelector.
function display() {
var x = document.getElementById("nav-content");
x.style.display = "none";
}
<header>
<div class="LiaWrapper clearfix">
<h1 id="logo">logo</h1>
<a href="" id="drop-down-icon" onclick="display()"><i class="fa fa-bars" aria-hidden="true"></i>
</a>
<nav id="nav-content">
<ul>
<li><a href="">Home</a></li>
<li><a href="">services</a></li>
<li><a href="">clients</a></li>
<li><a href="">about us</a></li>
<li><a href="">contact</a></li>
</ul>
</nav>
</div>
</header>
My goal is to successfully hide the navigation menu on click without any flickering issues.