I tried to make some divs on my website be toggled on/off when I press a button but it isn’t working for some reason, and always outputs this in the console:
This is my JavaScript:
function dropDown(id_parameter) {
var div = document.getElementById(id_parameter);
hideAll();
div.style.display = "block";
}
function hideAll() {
var x = document.getElementByID("div1");
x.style.display = "none";
var x = document.getElementByID("div2");
x.style.display = "none";
}
and my HTML is just
<div id="div1">
and
<a onclick="dropDown('div1');">
with a similar thing for div2.
I’m new to JavaScript and used what little knowledge I have of it to make this so if there are any syntax errors let me know.