Close mobile menu

This commit is contained in:
Maria Rushkova 2021-08-09 16:47:33 +02:00 committed by Jakub Sokołowski
parent a9281418c4
commit 3005be2d8e
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 22 additions and 20 deletions

View File

@ -1,29 +1,31 @@
"use strict";
'use strict';
const burger = document.querySelector(".burger");
const burgerOpen = document.querySelector(".burger__button--open");
const burgerClose = document.querySelector(".burger__button--close");
const menuMobile = document.querySelector(".nav-mobile");
const menuLinks = document.querySelectorAll(".nav__link");
const overlay = document.querySelector(".overlay");
const form = document.querySelector(".footer__form");
const confirmation = document.querySelector(".footer__confirm");
const burger = document.querySelector('.burger');
const burgerOpen = document.querySelector('.burger__button--open');
const burgerClose = document.querySelector('.burger__button--close');
const menuMobile = document.querySelector('.nav-mobile');
const menuLinks = document.querySelectorAll('.nav__link');
const overlay = document.querySelector('.overlay');
const form = document.querySelector('.footer__form');
const confirmation = document.querySelector('.footer__confirm');
const closeMobileMenu = () => {
burgerOpen.classList.toggle("hidden");
burgerClose.classList.toggle("hidden");
menuMobile.classList.toggle("hidden");
overlay.classList.toggle("hidden");
burgerOpen.classList.toggle('hidden');
burgerClose.classList.toggle('hidden');
menuMobile.classList.toggle('hidden');
overlay.classList.toggle('hidden');
};
burger.addEventListener("click", closeMobileMenu);
overlay.addEventListener("click", closeMobileMenu);
menuLinks.forEach(function (link) {
link.addEventListener("click", closeMobileMenu);
burger.addEventListener('click', closeMobileMenu);
overlay.addEventListener('click', closeMobileMenu);
menuLinks.forEach((link) => {
link.addEventListener('click', () => {
closeMobileMenu;
});
});
form.addEventListener("submit", function (e) {
form.addEventListener('submit', (e) => {
e.preventDefault();
form.classList.toggle("hidden");
confirmation.classList.toggle("hidden");
form.classList.toggle('hidden');
confirmation.classList.toggle('hidden');
});