100-project-100-days-website/100_projects/24-fullscreen-navigation/main.js
2023-03-17 16:54:04 +03:00
Ask

15 lines
397 B
JavaScript

{adc65e16729fd5c5d4f3531744942855caaeb1e8 true 397 main.js 0xc002a9b110}

let toggler = document.querySelector(".toggle");
let nav = document.querySelector("nav");
let close = document.querySelector(".close");
toggler.onclick = function () {
nav.classList.add("open");
};
close.onclick = function () {
this.parentElement.classList.remove("open");
};
document.onkeyup = function (e) {
if (e.key === "Escape") {
nav.classList.remove("open");
}
};