so I have a function that I call with onclick="openNav()" from an html element. This is my function:
function openNav() {
document.getElementById("nav-drawer").classList.add("nav-drawer-open");
blackout.style.display = "block";
setTimeout(() => {
blackout.classList.add("blackout-open");
}, 1);
}
This function works. The Page also knows that "blackout" = <div id="blackout"></div>
at any point, e.g. when I type blackout in the console, it will give me the correct div. So I am assuming, that "blackout" must be a global variable (probably something like var blackout = document.getElementById("blackout");
), but since I wrote this function a while ago, I can't remember where I defined that variable. I have searched all of my code and I don't seem to find it.
Does anybody have an idea, how this could work anyways, without me defining this variable manually? This is all very weird to me.