-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
22 lines (21 loc) · 746 Bytes
/
Copy pathscript.js
File metadata and controls
22 lines (21 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const btnMenu = document.querySelector("#btnMenu");
const menu = document.querySelector("#menu");
btnMenu.addEventListener("click", function () {
menu.classList.toggle("mostrar");
});
const subMenuBtn = document.querySelectorAll(".submenu-btn");
for (let i = 0; i < subMenuBtn.length; i++) {
subMenuBtn[i].addEventListener("click", function () {
if (window.innerWidth < 1024) {
const subMenu = this.nextElementSibling;
const height = subMenu.scrollHeight;
if (subMenu.classList.contains("desplegar")) {
subMenu.classList.remove("desplegar");
subMenu.removeAttribute("style");
} else {
subMenu.classList.add("desplegar");
subMenu.style.height = height + "px";
}
}
});
}