I don't know JavaScript yet but I am trying to run a JavaScript function when I click a div. The function will show another div with the class rightside. I have tried hrefs inside divs, divs inside hrefs and divs alone with onclick. When I insert a href to another page it works, I just can't seem to run the JS. I've read various posts and to my eye I am doing exactly what others seem to have succeeded doing.
In the body:
<div class="level3 nam col10" id="box10" onclick="loadLeftBar()"><p></p></div>
In the head (for now until I can get this to work and put in a separate .js file):
<script>function loadLeftBar() {
var x = document.getElementsByClassName("rightside");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}</script>
CSS for the DIV I'm trying to show on click:
.rightside {
display: none;
width: 35%;
height: 39vw;
position: absolute;
top: 2.3vw;
right: 2.3vw;
z-index: 3;
background-color: lawngreen;
border: solid black;
overflow-x: hidden;
overflow-y: scroll;
}