Skip to content

Commit

Permalink
more codes
Browse files Browse the repository at this point in the history
  • Loading branch information
jen67 committed Dec 16, 2023
1 parent b818c77 commit 24b44bd
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions J-query-sidenav/script.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
(function () {

"use strict";


// Hide all submenus
function hideSubmenus() {
const subMenus = document.querySelectorAll("ul li ul");
for (var i = 0; i < subMenus.length; i++) {
for (let i = 0; i < subMenus.length; i++) {
subMenus[i].className = "hide-menu";
}
}

hideSubmenus();
hideSubmenus();


const menuLinks = document.querySelectorAll(".menulink");

for (var i = 0; i < menuLinks.length; i++) {
for (let i = 0; i < menuLinks.length; i++) {
menuLinks[i].addEventListener("click", function (e) {
e.preventDefault();
thisMenu = this.parentNode.querySelector("ul");
let thisMenu = this.parentNode.querySelector("ul");
if (thisMenu.classList.contains("hide-menu")) {
hideSubmenus();
thisMenu.className = "show-menu";
Expand Down

0 comments on commit 24b44bd

Please sign in to comment.