While working on my website and trying to add a close menu button, I encountered an issue where all the menu buttons stopped functioning. Here is the HTML code snippet:
<div id="openMenuButton">
<span style= "font-size:30px;cursor:pointer"
onclick="openMenu()">☰ Menu
</span>
</div>
<div id="menu">
<div id="closebtn">
<span style= "font-size:36px;cursor:pointer"
onclick="closeMenu()">× Close
</span>
</div>
<div id="menu-items">
<a href="/" class="menu-item">Home</a>
<a href="games/" class="menu-item">Games</a>
<a href="/" class="menu-item">About</a>
<a href="/" class="menu-item">Contact Us</a>
</div>
<div id="menu-background-pattern"></div>
</div>
Additionally, here is the CSS affecting this functionality:
body {
background-color: rgb(20, 20, 20);
margin: 0px;
}
/* CSS rules for menu styling */
Lastly, here is the JavaScript functions for opening and closing the menu:
function openMenu() {
document.getElementById("menu").style.width = "100%";
}
function closeMenu() {
document.getElementById("menu").style.width = "0";
}
I've attempted some modifications in the code but the issue persisted, becoming even more erratic. Seeking guidance on resolving this dilemma.