I've encountered an issue with a function not being called properly. The error message states "TypeError: menu is not a function." I attempted to troubleshoot by moving the function before the HTML that calls it, but unfortunately, this did not resolve the problem.
<script>
var dropdown = document.querySelector("nav .dropdown");
var menu = document.querySelector("nav div .menu");
function menu()
{
if(dropdown.style.display === "none")
{
dropdown.style.display = "grid";
}
else
{
dropdown.style.display = "none";
}
} </script>
<input class="button" type="button" onclick="location.href='Controller/logout.php';" value="logout" /> <nav>
<div class="content">
<div class="links">
<a href="Home">Home</a>
<a href="Portfolio">Portfolio</a>
<a href="Reviews">Reviews</a>
</div>
<i class="material-icons menu" onclick="menu()">menu</i>
</div>
<div class="dropdown">
<a href="Home">Home</a>
<a href="Portfolio">Portfolio</a>
<a href="Reviews">Reviews</a>
</div> </nav>