Skip to content

Commit

Permalink
Toggle button for login page
Browse files Browse the repository at this point in the history
  • Loading branch information
Zohreh-sa committed Dec 3, 2024
1 parent b832dca commit 7991fd8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions login.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
<a class="submit-image">Submit an image</a>

<a class="logIn" title="Login-button" href="./login.html">Login</a>
<button class="toggle">&#9776;</button>

<div class="toggle-items">
<a class="about-us" href="#">About us </a>
<a class="contact-us" href="#"> Contact us</a>

</div>

</div>

Expand Down
22 changes: 22 additions & 0 deletions login.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,25 @@ document.getElementById("loginForm").addEventListener("submit", function (event)
}
});



const toggleButton = document.querySelector('.toggle');
const toggleItems = document.querySelector('.toggle-items');

// Toggle menu visibility when the button is clicked
toggleButton.addEventListener('click', (event) => {
toggleItems.classList.toggle('active');
event.stopPropagation(); // Stop click from propagating
});

// Close the menu when clicking outside
document.addEventListener('click', () => {
if (toggleItems.classList.contains('active')) {
toggleItems.classList.remove('active');
}
});

// Prevent menu clicks from closing it
toggleItems.addEventListener('click', (event) => {
event.stopPropagation();
});

0 comments on commit 7991fd8

Please sign in to comment.