Hi everyone. Currently doing challenge: “Build a Technical Documentation Page”.
I’ve finished HTML and CSS and I’m happy with that. It passes all tests.
However, I’m having trouble with Javascript. Haven’t done the Javascript course yet.
My goal: On screen-sizes with a width of <=1365, I want to close the drop-down menu when the user clicks a link in the menu.
However, I’m unable to do it because I keep getting this error:
Uncaught TypeError: listener.addEventListener is not a function
at window.onload (documentation.js:13)
Here is my Javascript code:
var readyState = document;
if (readyState = "complete") {
if (window.innerWidth <= 1365) {
function off () {
subMenu = "off";
}
window.onload = function() {
var subMenu = document.getElementById("toggle-mobile-menu").value;
var listener = document.getElementsByClassName("nav-link");
listener.addEventListener('click', off);
}
}
}
Here is my Codepen for the Project: https://codepen.io/xarmar/pen/rNjJjXK
Thanks in advance.