-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
32 lines (26 loc) · 1011 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
//function to highlight current menu on click
function highlightCurrentURL() {
var a = document.getElementById("navig").getElementsByTagName('a');
for (var i = 0; i < a.length; i++) {
if (a[i].href.split("#")[0] == document.location.href.split('#')[0]) {
a[i].className = "current";
}
}
}
window.onload = function() {
highlightCurrentURL();
}
//mobile-nav-toggle Hamburger Menu
const primaryNav = document.querySelector(".primary-navigation");
const navToggle = document.querySelector(".mobile-nav-toggle");
navToggle.addEventListener("click", () => {
const visibility = primaryNav.getAttribute("data-visible");
if(visibility === "false") {
primaryNav.setAttribute("data-visible", true);
navToggle.setAttribute("aria-expanded", true);
}
else if (visibility === "true") {
primaryNav.setAttribute("data-visible", false);
navToggle.setAttribute("aria-expanded", false);
}
});