-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated index.html, main.js and styles.css
- Loading branch information
1 parent
5847dba
commit f2339d2
Showing
3 changed files
with
144 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
document.addEventListener("DOMContentLoaded", function () { | ||
// Select the navigation bar, open icon, and close icon from the HTML and store in variables | ||
const menuIcon = document.getElementById("open-icon"); | ||
const navBar = document.querySelector(".menu-items"); | ||
const closeIcon = document.getElementById("close-icon"); | ||
|
||
// Add event listeners to close the menu icon, display the close icon and the | ||
// navbar when the user clicks to open the menu | ||
menuIcon.addEventListener("click", () => { | ||
// Toggle the "open" class on the navigation bar to show it | ||
navBar.classList.toggle("open"); | ||
|
||
// Hide the menu icon and display the close icon | ||
menuIcon.style.display = "none"; | ||
closeIcon.style.display = "block"; | ||
}); | ||
|
||
// Add event listener to close the menu on click of the close icon | ||
closeIcon.addEventListener("click", () => { | ||
// Remove the "open" class from the navigation bar to hide it | ||
navBar.classList.remove("open"); | ||
|
||
// Display the menu icon and hide the close icon | ||
menuIcon.style.display = "flex"; | ||
closeIcon.style.display = "none"; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters