-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
33 lines (27 loc) · 967 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const nav = document.querySelector('.navbar');
const navToggle = document.querySelector('.nav_toggle');
const navItem = document.querySelectorAll('.primary_nav_items');
const primaryNav = document.querySelector('.primary_nav');
navToggle.addEventListener('click', () => {
nav.classList.toggle('open');
})
navItem.forEach((item, index) => {
item.addEventListener('click', () => {
item.parentNode.classList.toggle('openItem')
})
})
// let navSelection = "";
// primaryNav.addEventListener('click', (e) => {
// let selectedOption = e.target;
// if (navSelection) {
// navSelection.parentNode.classList.remove('openItem');
// }
// navSelection = selectedOption
// if (selectedOption.parentNode.classList.contains == 'openItem') {
// console.log("contains")
// selectedOption.parentNode.classList.remove('openItem');
// } else {
// console.log("does not")
// selectedOption.parentNode.classList.add('openItem');
// }
// })