I have a button in my HTML file:
<button class="nav__btn resbtn" onclick="resumeNavToggle()">Resume</button>
which calls a function from a separate javascript file:
function resumeNavToggle() {
let resBtn = document.querySelector(".resbtn");
let resNav = document.querySelector(".resume__subnav");
let resNavSub1 = document.querySelector(".resume__subnav1");
let resNavSub2 = document.querySelector(".resume__subnav2");
let licNav = document.querySelector(".liccer__subnav");
let couNav = document.querySelector(".courses__subnav");
let licBtn = document.querySelector(".licbtn");
let couBtn = document.querySelector(".coubtn");
if (resNav.style.display === "none") {
resBtn.style.backgroundColor = "#01050a";
resNav.style.display = "grid";
// A BUNCH OF STYLE CHANGES CUT TO MAKE THINGS EASIER
licBtn.style.backgroundColor = "#010a13";
couBtn.style.backgroundColor = "#010a13";
} else {
resNav.style.display = "none";
}
}
But the button is not calling the function on the first click, only on the second click onwards. Any ideas as to what could be causing this?