'document.getElementById('#ham') doesn't find the element
Whenever I add an addEventListener, or a toggle in javascript, I get ''can't read **** of null" or ''can't read of undefined". I tried many different ways to solve it, deleting the javascript file and recreating it, putting everything inside an "addEventListener('DOMContentLoaded, ...'), moving the javascript code in html file. Nothing works, I don't know why. I tried all the ways that they say on the internet that work.
const hamn= document.getElementById('#ham')
const navLinks= document.getElementById('#navLink')
function openMenu() {
navLinks.classList.toggle('hidden')
}
hamn.addEventListener('click', openMenu)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
